mirror of
https://github.com/ADElectronics/RTL00_WEB_WS2812.git
synced 2025-07-31 20:31:07 +00:00
1st
This commit is contained in:
parent
7f07f696e1
commit
c6c5eeed6f
1170 changed files with 608790 additions and 1 deletions
1661
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/cmsis/core_cm3.h
Normal file
1661
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/cmsis/core_cm3.h
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,636 @@
|
|||
/**************************************************************************//**
|
||||
* @file core_cmFunc.h
|
||||
* @brief CMSIS Cortex-M Core Function Access Header File
|
||||
* @version V3.20
|
||||
* @date 25. February 2013
|
||||
*
|
||||
* @note
|
||||
*
|
||||
******************************************************************************/
|
||||
/* Copyright (c) 2009 - 2013 ARM LIMITED
|
||||
|
||||
All rights reserved.
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
- Neither the name of ARM nor the names of its contributors may be used
|
||||
to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
*
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef __CORE_CMFUNC_H
|
||||
#define __CORE_CMFUNC_H
|
||||
|
||||
|
||||
/* ########################### Core Function Access ########################### */
|
||||
/** \ingroup CMSIS_Core_FunctionInterface
|
||||
\defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
|
||||
@{
|
||||
*/
|
||||
|
||||
#if defined ( __CC_ARM ) /*------------------RealView Compiler -----------------*/
|
||||
/* ARM armcc specific functions */
|
||||
|
||||
#if (__ARMCC_VERSION < 400677)
|
||||
#error "Please use ARM Compiler Toolchain V4.0.677 or later!"
|
||||
#endif
|
||||
|
||||
/* intrinsic void __enable_irq(); */
|
||||
/* intrinsic void __disable_irq(); */
|
||||
|
||||
/** \brief Get Control Register
|
||||
|
||||
This function returns the content of the Control Register.
|
||||
|
||||
\return Control Register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_CONTROL(void)
|
||||
{
|
||||
register uint32_t __regControl __ASM("control");
|
||||
return(__regControl);
|
||||
}
|
||||
|
||||
|
||||
/** \brief Set Control Register
|
||||
|
||||
This function writes the given value to the Control Register.
|
||||
|
||||
\param [in] control Control Register value to set
|
||||
*/
|
||||
__STATIC_INLINE void __set_CONTROL(uint32_t control)
|
||||
{
|
||||
register uint32_t __regControl __ASM("control");
|
||||
__regControl = control;
|
||||
}
|
||||
|
||||
|
||||
/** \brief Get IPSR Register
|
||||
|
||||
This function returns the content of the IPSR Register.
|
||||
|
||||
\return IPSR Register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_IPSR(void)
|
||||
{
|
||||
register uint32_t __regIPSR __ASM("ipsr");
|
||||
return(__regIPSR);
|
||||
}
|
||||
|
||||
|
||||
/** \brief Get APSR Register
|
||||
|
||||
This function returns the content of the APSR Register.
|
||||
|
||||
\return APSR Register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_APSR(void)
|
||||
{
|
||||
register uint32_t __regAPSR __ASM("apsr");
|
||||
return(__regAPSR);
|
||||
}
|
||||
|
||||
|
||||
/** \brief Get xPSR Register
|
||||
|
||||
This function returns the content of the xPSR Register.
|
||||
|
||||
\return xPSR Register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_xPSR(void)
|
||||
{
|
||||
register uint32_t __regXPSR __ASM("xpsr");
|
||||
return(__regXPSR);
|
||||
}
|
||||
|
||||
|
||||
/** \brief Get Process Stack Pointer
|
||||
|
||||
This function returns the current value of the Process Stack Pointer (PSP).
|
||||
|
||||
\return PSP Register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_PSP(void)
|
||||
{
|
||||
register uint32_t __regProcessStackPointer __ASM("psp");
|
||||
return(__regProcessStackPointer);
|
||||
}
|
||||
|
||||
|
||||
/** \brief Set Process Stack Pointer
|
||||
|
||||
This function assigns the given value to the Process Stack Pointer (PSP).
|
||||
|
||||
\param [in] topOfProcStack Process Stack Pointer value to set
|
||||
*/
|
||||
__STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
|
||||
{
|
||||
register uint32_t __regProcessStackPointer __ASM("psp");
|
||||
__regProcessStackPointer = topOfProcStack;
|
||||
}
|
||||
|
||||
|
||||
/** \brief Get Main Stack Pointer
|
||||
|
||||
This function returns the current value of the Main Stack Pointer (MSP).
|
||||
|
||||
\return MSP Register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_MSP(void)
|
||||
{
|
||||
register uint32_t __regMainStackPointer __ASM("msp");
|
||||
return(__regMainStackPointer);
|
||||
}
|
||||
|
||||
|
||||
/** \brief Set Main Stack Pointer
|
||||
|
||||
This function assigns the given value to the Main Stack Pointer (MSP).
|
||||
|
||||
\param [in] topOfMainStack Main Stack Pointer value to set
|
||||
*/
|
||||
__STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
|
||||
{
|
||||
register uint32_t __regMainStackPointer __ASM("msp");
|
||||
__regMainStackPointer = topOfMainStack;
|
||||
}
|
||||
|
||||
|
||||
/** \brief Get Priority Mask
|
||||
|
||||
This function returns the current state of the priority mask bit from the Priority Mask Register.
|
||||
|
||||
\return Priority Mask value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_PRIMASK(void)
|
||||
{
|
||||
register uint32_t __regPriMask __ASM("primask");
|
||||
return(__regPriMask);
|
||||
}
|
||||
|
||||
|
||||
/** \brief Set Priority Mask
|
||||
|
||||
This function assigns the given value to the Priority Mask Register.
|
||||
|
||||
\param [in] priMask Priority Mask
|
||||
*/
|
||||
__STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
|
||||
{
|
||||
register uint32_t __regPriMask __ASM("primask");
|
||||
__regPriMask = (priMask);
|
||||
}
|
||||
|
||||
|
||||
#if (__CORTEX_M >= 0x03)
|
||||
|
||||
/** \brief Enable FIQ
|
||||
|
||||
This function enables FIQ interrupts by clearing the F-bit in the CPSR.
|
||||
Can only be executed in Privileged modes.
|
||||
*/
|
||||
#define __enable_fault_irq __enable_fiq
|
||||
|
||||
|
||||
/** \brief Disable FIQ
|
||||
|
||||
This function disables FIQ interrupts by setting the F-bit in the CPSR.
|
||||
Can only be executed in Privileged modes.
|
||||
*/
|
||||
#define __disable_fault_irq __disable_fiq
|
||||
|
||||
|
||||
/** \brief Get Base Priority
|
||||
|
||||
This function returns the current value of the Base Priority register.
|
||||
|
||||
\return Base Priority register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_BASEPRI(void)
|
||||
{
|
||||
register uint32_t __regBasePri __ASM("basepri");
|
||||
return(__regBasePri);
|
||||
}
|
||||
|
||||
|
||||
/** \brief Set Base Priority
|
||||
|
||||
This function assigns the given value to the Base Priority register.
|
||||
|
||||
\param [in] basePri Base Priority value to set
|
||||
*/
|
||||
__STATIC_INLINE void __set_BASEPRI(uint32_t basePri)
|
||||
{
|
||||
register uint32_t __regBasePri __ASM("basepri");
|
||||
__regBasePri = (basePri & 0xff);
|
||||
}
|
||||
|
||||
|
||||
/** \brief Get Fault Mask
|
||||
|
||||
This function returns the current value of the Fault Mask register.
|
||||
|
||||
\return Fault Mask register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_FAULTMASK(void)
|
||||
{
|
||||
register uint32_t __regFaultMask __ASM("faultmask");
|
||||
return(__regFaultMask);
|
||||
}
|
||||
|
||||
|
||||
/** \brief Set Fault Mask
|
||||
|
||||
This function assigns the given value to the Fault Mask register.
|
||||
|
||||
\param [in] faultMask Fault Mask value to set
|
||||
*/
|
||||
__STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
|
||||
{
|
||||
register uint32_t __regFaultMask __ASM("faultmask");
|
||||
__regFaultMask = (faultMask & (uint32_t)1);
|
||||
}
|
||||
|
||||
#endif /* (__CORTEX_M >= 0x03) */
|
||||
|
||||
|
||||
#if (__CORTEX_M == 0x04)
|
||||
|
||||
/** \brief Get FPSCR
|
||||
|
||||
This function returns the current value of the Floating Point Status/Control register.
|
||||
|
||||
\return Floating Point Status/Control register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_FPSCR(void)
|
||||
{
|
||||
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
|
||||
register uint32_t __regfpscr __ASM("fpscr");
|
||||
return(__regfpscr);
|
||||
#else
|
||||
return(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/** \brief Set FPSCR
|
||||
|
||||
This function assigns the given value to the Floating Point Status/Control register.
|
||||
|
||||
\param [in] fpscr Floating Point Status/Control value to set
|
||||
*/
|
||||
__STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
|
||||
{
|
||||
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
|
||||
register uint32_t __regfpscr __ASM("fpscr");
|
||||
__regfpscr = (fpscr);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* (__CORTEX_M == 0x04) */
|
||||
|
||||
|
||||
#elif defined ( __ICCARM__ ) /*------------------ ICC Compiler -------------------*/
|
||||
/* IAR iccarm specific functions */
|
||||
|
||||
// #include <cmsis_iar.h>
|
||||
|
||||
|
||||
#elif defined ( __TMS470__ ) /*---------------- TI CCS Compiler ------------------*/
|
||||
/* TI CCS specific functions */
|
||||
|
||||
#include <cmsis_ccs.h>
|
||||
|
||||
|
||||
#elif defined ( __GNUC__ ) /*------------------ GNU Compiler ---------------------*/
|
||||
/* GNU gcc specific functions */
|
||||
|
||||
/** \brief Enable IRQ Interrupts
|
||||
|
||||
This function enables IRQ interrupts by clearing the I-bit in the CPSR.
|
||||
Can only be executed in Privileged modes.
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_irq(void)
|
||||
{
|
||||
__ASM volatile ("cpsie i" : : : "memory");
|
||||
}
|
||||
|
||||
|
||||
/** \brief Disable IRQ Interrupts
|
||||
|
||||
This function disables IRQ interrupts by setting the I-bit in the CPSR.
|
||||
Can only be executed in Privileged modes.
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_irq(void)
|
||||
{
|
||||
__ASM volatile ("cpsid i" : : : "memory");
|
||||
}
|
||||
|
||||
|
||||
/** \brief Get Control Register
|
||||
|
||||
This function returns the content of the Control Register.
|
||||
|
||||
\return Control Register value
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_CONTROL(void)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__ASM volatile ("MRS %0, control" : "=r" (result) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
/** \brief Set Control Register
|
||||
|
||||
This function writes the given value to the Control Register.
|
||||
|
||||
\param [in] control Control Register value to set
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_CONTROL(uint32_t control)
|
||||
{
|
||||
__ASM volatile ("MSR control, %0" : : "r" (control) : "memory");
|
||||
}
|
||||
|
||||
|
||||
/** \brief Get IPSR Register
|
||||
|
||||
This function returns the content of the IPSR Register.
|
||||
|
||||
\return IPSR Register value
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_IPSR(void)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__ASM volatile ("MRS %0, ipsr" : "=r" (result) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
/** \brief Get APSR Register
|
||||
|
||||
This function returns the content of the APSR Register.
|
||||
|
||||
\return APSR Register value
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_APSR(void)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__ASM volatile ("MRS %0, apsr" : "=r" (result) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
/** \brief Get xPSR Register
|
||||
|
||||
This function returns the content of the xPSR Register.
|
||||
|
||||
\return xPSR Register value
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_xPSR(void)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__ASM volatile ("MRS %0, xpsr" : "=r" (result) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
/** \brief Get Process Stack Pointer
|
||||
|
||||
This function returns the current value of the Process Stack Pointer (PSP).
|
||||
|
||||
\return PSP Register value
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PSP(void)
|
||||
{
|
||||
register uint32_t result;
|
||||
|
||||
__ASM volatile ("MRS %0, psp\n" : "=r" (result) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
/** \brief Set Process Stack Pointer
|
||||
|
||||
This function assigns the given value to the Process Stack Pointer (PSP).
|
||||
|
||||
\param [in] topOfProcStack Process Stack Pointer value to set
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
|
||||
{
|
||||
__ASM volatile ("MSR psp, %0\n" : : "r" (topOfProcStack) : "sp");
|
||||
}
|
||||
|
||||
|
||||
/** \brief Get Main Stack Pointer
|
||||
|
||||
This function returns the current value of the Main Stack Pointer (MSP).
|
||||
|
||||
\return MSP Register value
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_MSP(void)
|
||||
{
|
||||
register uint32_t result;
|
||||
|
||||
__ASM volatile ("MRS %0, msp\n" : "=r" (result) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
/** \brief Set Main Stack Pointer
|
||||
|
||||
This function assigns the given value to the Main Stack Pointer (MSP).
|
||||
|
||||
\param [in] topOfMainStack Main Stack Pointer value to set
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
|
||||
{
|
||||
__ASM volatile ("MSR msp, %0\n" : : "r" (topOfMainStack) : "sp");
|
||||
}
|
||||
|
||||
|
||||
/** \brief Get Priority Mask
|
||||
|
||||
This function returns the current state of the priority mask bit from the Priority Mask Register.
|
||||
|
||||
\return Priority Mask value
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PRIMASK(void)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__ASM volatile ("MRS %0, primask" : "=r" (result) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
/** \brief Set Priority Mask
|
||||
|
||||
This function assigns the given value to the Priority Mask Register.
|
||||
|
||||
\param [in] priMask Priority Mask
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
|
||||
{
|
||||
__ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
|
||||
}
|
||||
|
||||
|
||||
#if (__CORTEX_M >= 0x03)
|
||||
|
||||
/** \brief Enable FIQ
|
||||
|
||||
This function enables FIQ interrupts by clearing the F-bit in the CPSR.
|
||||
Can only be executed in Privileged modes.
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_fault_irq(void)
|
||||
{
|
||||
__ASM volatile ("cpsie f" : : : "memory");
|
||||
}
|
||||
|
||||
|
||||
/** \brief Disable FIQ
|
||||
|
||||
This function disables FIQ interrupts by setting the F-bit in the CPSR.
|
||||
Can only be executed in Privileged modes.
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_fault_irq(void)
|
||||
{
|
||||
__ASM volatile ("cpsid f" : : : "memory");
|
||||
}
|
||||
|
||||
|
||||
/** \brief Get Base Priority
|
||||
|
||||
This function returns the current value of the Base Priority register.
|
||||
|
||||
\return Base Priority register value
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_BASEPRI(void)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__ASM volatile ("MRS %0, basepri_max" : "=r" (result) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
/** \brief Set Base Priority
|
||||
|
||||
This function assigns the given value to the Base Priority register.
|
||||
|
||||
\param [in] basePri Base Priority value to set
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_BASEPRI(uint32_t value)
|
||||
{
|
||||
__ASM volatile ("MSR basepri, %0" : : "r" (value) : "memory");
|
||||
}
|
||||
|
||||
|
||||
/** \brief Get Fault Mask
|
||||
|
||||
This function returns the current value of the Fault Mask register.
|
||||
|
||||
\return Fault Mask register value
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FAULTMASK(void)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__ASM volatile ("MRS %0, faultmask" : "=r" (result) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
/** \brief Set Fault Mask
|
||||
|
||||
This function assigns the given value to the Fault Mask register.
|
||||
|
||||
\param [in] faultMask Fault Mask value to set
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
|
||||
{
|
||||
__ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory");
|
||||
}
|
||||
|
||||
#endif /* (__CORTEX_M >= 0x03) */
|
||||
|
||||
|
||||
#if (__CORTEX_M == 0x04)
|
||||
|
||||
/** \brief Get FPSCR
|
||||
|
||||
This function returns the current value of the Floating Point Status/Control register.
|
||||
|
||||
\return Floating Point Status/Control register value
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FPSCR(void)
|
||||
{
|
||||
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
|
||||
uint32_t result;
|
||||
|
||||
/* Empty asm statement works as a scheduling barrier */
|
||||
__ASM volatile ("");
|
||||
__ASM volatile ("VMRS %0, fpscr" : "=r" (result) );
|
||||
__ASM volatile ("");
|
||||
return(result);
|
||||
#else
|
||||
return(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/** \brief Set FPSCR
|
||||
|
||||
This function assigns the given value to the Floating Point Status/Control register.
|
||||
|
||||
\param [in] fpscr Floating Point Status/Control value to set
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
|
||||
{
|
||||
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
|
||||
/* Empty asm statement works as a scheduling barrier */
|
||||
__ASM volatile ("");
|
||||
__ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc");
|
||||
__ASM volatile ("");
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* (__CORTEX_M == 0x04) */
|
||||
|
||||
|
||||
#elif defined ( __TASKING__ ) /*------------------ TASKING Compiler --------------*/
|
||||
/* TASKING carm specific functions */
|
||||
|
||||
/*
|
||||
* The CMSIS functions have been implemented as intrinsics in the compiler.
|
||||
* Please use "carm -?i" to get an up to date list of all instrinsics,
|
||||
* Including the CMSIS ones.
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
/*@} end of CMSIS_Core_RegAccFunctions */
|
||||
|
||||
|
||||
#endif /* __CORE_CMFUNC_H */
|
||||
|
|
@ -0,0 +1,688 @@
|
|||
/**************************************************************************//**
|
||||
* @file core_cmInstr.h
|
||||
* @brief CMSIS Cortex-M Core Instruction Access Header File
|
||||
* @version V3.20
|
||||
* @date 05. March 2013
|
||||
*
|
||||
* @note
|
||||
*
|
||||
******************************************************************************/
|
||||
/* Copyright (c) 2009 - 2013 ARM LIMITED
|
||||
|
||||
All rights reserved.
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
- Neither the name of ARM nor the names of its contributors may be used
|
||||
to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
*
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef __CORE_CMINSTR_H
|
||||
#define __CORE_CMINSTR_H
|
||||
|
||||
|
||||
/* ########################## Core Instruction Access ######################### */
|
||||
/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
|
||||
Access to dedicated instructions
|
||||
@{
|
||||
*/
|
||||
|
||||
#if defined ( __CC_ARM ) /*------------------RealView Compiler -----------------*/
|
||||
/* ARM armcc specific functions */
|
||||
|
||||
#if (__ARMCC_VERSION < 400677)
|
||||
#error "Please use ARM Compiler Toolchain V4.0.677 or later!"
|
||||
#endif
|
||||
|
||||
|
||||
/** \brief No Operation
|
||||
|
||||
No Operation does nothing. This instruction can be used for code alignment purposes.
|
||||
*/
|
||||
#define __NOP __nop
|
||||
|
||||
|
||||
/** \brief Wait For Interrupt
|
||||
|
||||
Wait For Interrupt is a hint instruction that suspends execution
|
||||
until one of a number of events occurs.
|
||||
*/
|
||||
#define __WFI __wfi
|
||||
|
||||
|
||||
/** \brief Wait For Event
|
||||
|
||||
Wait For Event is a hint instruction that permits the processor to enter
|
||||
a low-power state until one of a number of events occurs.
|
||||
*/
|
||||
#define __WFE __wfe
|
||||
|
||||
|
||||
/** \brief Send Event
|
||||
|
||||
Send Event is a hint instruction. It causes an event to be signaled to the CPU.
|
||||
*/
|
||||
#define __SEV __sev
|
||||
|
||||
|
||||
/** \brief Instruction Synchronization Barrier
|
||||
|
||||
Instruction Synchronization Barrier flushes the pipeline in the processor,
|
||||
so that all instructions following the ISB are fetched from cache or
|
||||
memory, after the instruction has been completed.
|
||||
*/
|
||||
#define __ISB() __isb(0xF)
|
||||
|
||||
|
||||
/** \brief Data Synchronization Barrier
|
||||
|
||||
This function acts as a special kind of Data Memory Barrier.
|
||||
It completes when all explicit memory accesses before this instruction complete.
|
||||
*/
|
||||
#define __DSB() __dsb(0xF)
|
||||
|
||||
|
||||
/** \brief Data Memory Barrier
|
||||
|
||||
This function ensures the apparent order of the explicit memory operations before
|
||||
and after the instruction, without ensuring their completion.
|
||||
*/
|
||||
#define __DMB() __dmb(0xF)
|
||||
|
||||
|
||||
/** \brief Reverse byte order (32 bit)
|
||||
|
||||
This function reverses the byte order in integer value.
|
||||
|
||||
\param [in] value Value to reverse
|
||||
\return Reversed value
|
||||
*/
|
||||
#define __REV __rev
|
||||
|
||||
|
||||
/** \brief Reverse byte order (16 bit)
|
||||
|
||||
This function reverses the byte order in two unsigned short values.
|
||||
|
||||
\param [in] value Value to reverse
|
||||
\return Reversed value
|
||||
*/
|
||||
#ifndef __NO_EMBEDDED_ASM
|
||||
__attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value)
|
||||
{
|
||||
rev16 r0, r0
|
||||
bx lr
|
||||
}
|
||||
#endif
|
||||
|
||||
/** \brief Reverse byte order in signed short value
|
||||
|
||||
This function reverses the byte order in a signed short value with sign extension to integer.
|
||||
|
||||
\param [in] value Value to reverse
|
||||
\return Reversed value
|
||||
*/
|
||||
#ifndef __NO_EMBEDDED_ASM
|
||||
__attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int32_t __REVSH(int32_t value)
|
||||
{
|
||||
revsh r0, r0
|
||||
bx lr
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/** \brief Rotate Right in unsigned value (32 bit)
|
||||
|
||||
This function Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
|
||||
|
||||
\param [in] value Value to rotate
|
||||
\param [in] value Number of Bits to rotate
|
||||
\return Rotated value
|
||||
*/
|
||||
#define __ROR __ror
|
||||
|
||||
|
||||
/** \brief Breakpoint
|
||||
|
||||
This function causes the processor to enter Debug state.
|
||||
Debug tools can use this to investigate system state when the instruction at a particular address is reached.
|
||||
|
||||
\param [in] value is ignored by the processor.
|
||||
If required, a debugger can use it to store additional information about the breakpoint.
|
||||
*/
|
||||
#define __BKPT(value) __breakpoint(value)
|
||||
|
||||
|
||||
#if (__CORTEX_M >= 0x03)
|
||||
|
||||
/** \brief Reverse bit order of value
|
||||
|
||||
This function reverses the bit order of the given value.
|
||||
|
||||
\param [in] value Value to reverse
|
||||
\return Reversed value
|
||||
*/
|
||||
#define __RBIT __rbit
|
||||
|
||||
|
||||
/** \brief LDR Exclusive (8 bit)
|
||||
|
||||
This function performs a exclusive LDR command for 8 bit value.
|
||||
|
||||
\param [in] ptr Pointer to data
|
||||
\return value of type uint8_t at (*ptr)
|
||||
*/
|
||||
#define __LDREXB(ptr) ((uint8_t ) __ldrex(ptr))
|
||||
|
||||
|
||||
/** \brief LDR Exclusive (16 bit)
|
||||
|
||||
This function performs a exclusive LDR command for 16 bit values.
|
||||
|
||||
\param [in] ptr Pointer to data
|
||||
\return value of type uint16_t at (*ptr)
|
||||
*/
|
||||
#define __LDREXH(ptr) ((uint16_t) __ldrex(ptr))
|
||||
|
||||
|
||||
/** \brief LDR Exclusive (32 bit)
|
||||
|
||||
This function performs a exclusive LDR command for 32 bit values.
|
||||
|
||||
\param [in] ptr Pointer to data
|
||||
\return value of type uint32_t at (*ptr)
|
||||
*/
|
||||
#define __LDREXW(ptr) ((uint32_t ) __ldrex(ptr))
|
||||
|
||||
|
||||
/** \brief STR Exclusive (8 bit)
|
||||
|
||||
This function performs a exclusive STR command for 8 bit values.
|
||||
|
||||
\param [in] value Value to store
|
||||
\param [in] ptr Pointer to location
|
||||
\return 0 Function succeeded
|
||||
\return 1 Function failed
|
||||
*/
|
||||
#define __STREXB(value, ptr) __strex(value, ptr)
|
||||
|
||||
|
||||
/** \brief STR Exclusive (16 bit)
|
||||
|
||||
This function performs a exclusive STR command for 16 bit values.
|
||||
|
||||
\param [in] value Value to store
|
||||
\param [in] ptr Pointer to location
|
||||
\return 0 Function succeeded
|
||||
\return 1 Function failed
|
||||
*/
|
||||
#define __STREXH(value, ptr) __strex(value, ptr)
|
||||
|
||||
|
||||
/** \brief STR Exclusive (32 bit)
|
||||
|
||||
This function performs a exclusive STR command for 32 bit values.
|
||||
|
||||
\param [in] value Value to store
|
||||
\param [in] ptr Pointer to location
|
||||
\return 0 Function succeeded
|
||||
\return 1 Function failed
|
||||
*/
|
||||
#define __STREXW(value, ptr) __strex(value, ptr)
|
||||
|
||||
|
||||
/** \brief Remove the exclusive lock
|
||||
|
||||
This function removes the exclusive lock which is created by LDREX.
|
||||
|
||||
*/
|
||||
#define __CLREX __clrex
|
||||
|
||||
|
||||
/** \brief Signed Saturate
|
||||
|
||||
This function saturates a signed value.
|
||||
|
||||
\param [in] value Value to be saturated
|
||||
\param [in] sat Bit position to saturate to (1..32)
|
||||
\return Saturated value
|
||||
*/
|
||||
#define __SSAT __ssat
|
||||
|
||||
|
||||
/** \brief Unsigned Saturate
|
||||
|
||||
This function saturates an unsigned value.
|
||||
|
||||
\param [in] value Value to be saturated
|
||||
\param [in] sat Bit position to saturate to (0..31)
|
||||
\return Saturated value
|
||||
*/
|
||||
#define __USAT __usat
|
||||
|
||||
|
||||
/** \brief Count leading zeros
|
||||
|
||||
This function counts the number of leading zeros of a data value.
|
||||
|
||||
\param [in] value Value to count the leading zeros
|
||||
\return number of leading zeros in value
|
||||
*/
|
||||
#define __CLZ __clz
|
||||
|
||||
#endif /* (__CORTEX_M >= 0x03) */
|
||||
|
||||
|
||||
|
||||
#elif defined ( __ICCARM__ ) /*------------------ ICC Compiler -------------------*/
|
||||
/* IAR iccarm specific functions */
|
||||
|
||||
// #include <cmsis_iar.h>
|
||||
|
||||
|
||||
#elif defined ( __TMS470__ ) /*---------------- TI CCS Compiler ------------------*/
|
||||
/* TI CCS specific functions */
|
||||
|
||||
#include <cmsis_ccs.h>
|
||||
|
||||
|
||||
#elif defined ( __GNUC__ ) /*------------------ GNU Compiler ---------------------*/
|
||||
/* GNU gcc specific functions */
|
||||
|
||||
/* Define macros for porting to both thumb1 and thumb2.
|
||||
* For thumb1, use low register (r0-r7), specified by constrant "l"
|
||||
* Otherwise, use general registers, specified by constrant "r" */
|
||||
#if defined (__thumb__) && !defined (__thumb2__)
|
||||
#define __CMSIS_GCC_OUT_REG(r) "=l" (r)
|
||||
#define __CMSIS_GCC_USE_REG(r) "l" (r)
|
||||
#else
|
||||
#define __CMSIS_GCC_OUT_REG(r) "=r" (r)
|
||||
#define __CMSIS_GCC_USE_REG(r) "r" (r)
|
||||
#endif
|
||||
|
||||
/** \brief No Operation
|
||||
|
||||
No Operation does nothing. This instruction can be used for code alignment purposes.
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE void __NOP(void)
|
||||
{
|
||||
__ASM volatile ("nop");
|
||||
}
|
||||
|
||||
|
||||
/** \brief Wait For Interrupt
|
||||
|
||||
Wait For Interrupt is a hint instruction that suspends execution
|
||||
until one of a number of events occurs.
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE void __WFI(void)
|
||||
{
|
||||
__ASM volatile ("wfi");
|
||||
}
|
||||
|
||||
|
||||
/** \brief Wait For Event
|
||||
|
||||
Wait For Event is a hint instruction that permits the processor to enter
|
||||
a low-power state until one of a number of events occurs.
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE void __WFE(void)
|
||||
{
|
||||
__ASM volatile ("wfe");
|
||||
}
|
||||
|
||||
|
||||
/** \brief Send Event
|
||||
|
||||
Send Event is a hint instruction. It causes an event to be signaled to the CPU.
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE void __SEV(void)
|
||||
{
|
||||
__ASM volatile ("sev");
|
||||
}
|
||||
|
||||
|
||||
/** \brief Instruction Synchronization Barrier
|
||||
|
||||
Instruction Synchronization Barrier flushes the pipeline in the processor,
|
||||
so that all instructions following the ISB are fetched from cache or
|
||||
memory, after the instruction has been completed.
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE void __ISB(void)
|
||||
{
|
||||
__ASM volatile ("isb");
|
||||
}
|
||||
|
||||
|
||||
/** \brief Data Synchronization Barrier
|
||||
|
||||
This function acts as a special kind of Data Memory Barrier.
|
||||
It completes when all explicit memory accesses before this instruction complete.
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE void __DSB(void)
|
||||
{
|
||||
__ASM volatile ("dsb");
|
||||
}
|
||||
|
||||
|
||||
/** \brief Data Memory Barrier
|
||||
|
||||
This function ensures the apparent order of the explicit memory operations before
|
||||
and after the instruction, without ensuring their completion.
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE void __DMB(void)
|
||||
{
|
||||
__ASM volatile ("dmb");
|
||||
}
|
||||
|
||||
|
||||
/** \brief Reverse byte order (32 bit)
|
||||
|
||||
This function reverses the byte order in integer value.
|
||||
|
||||
\param [in] value Value to reverse
|
||||
\return Reversed value
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __REV(uint32_t value)
|
||||
{
|
||||
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
|
||||
return __builtin_bswap32(value);
|
||||
#else
|
||||
uint32_t result;
|
||||
|
||||
__ASM volatile ("rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
|
||||
return(result);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/** \brief Reverse byte order (16 bit)
|
||||
|
||||
This function reverses the byte order in two unsigned short values.
|
||||
|
||||
\param [in] value Value to reverse
|
||||
\return Reversed value
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __REV16(uint32_t value)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__ASM volatile ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
/** \brief Reverse byte order in signed short value
|
||||
|
||||
This function reverses the byte order in a signed short value with sign extension to integer.
|
||||
|
||||
\param [in] value Value to reverse
|
||||
\return Reversed value
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE int32_t __REVSH(int32_t value)
|
||||
{
|
||||
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
|
||||
return (short)__builtin_bswap16(value);
|
||||
#else
|
||||
uint32_t result;
|
||||
|
||||
__ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
|
||||
return(result);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/** \brief Rotate Right in unsigned value (32 bit)
|
||||
|
||||
This function Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
|
||||
|
||||
\param [in] value Value to rotate
|
||||
\param [in] value Number of Bits to rotate
|
||||
\return Rotated value
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
|
||||
{
|
||||
return (op1 >> op2) | (op1 << (32 - op2));
|
||||
}
|
||||
|
||||
|
||||
/** \brief Breakpoint
|
||||
|
||||
This function causes the processor to enter Debug state.
|
||||
Debug tools can use this to investigate system state when the instruction at a particular address is reached.
|
||||
|
||||
\param [in] value is ignored by the processor.
|
||||
If required, a debugger can use it to store additional information about the breakpoint.
|
||||
*/
|
||||
#define __BKPT(value) __ASM volatile ("bkpt "#value)
|
||||
|
||||
|
||||
#if (__CORTEX_M >= 0x03)
|
||||
|
||||
/** \brief Reverse bit order of value
|
||||
|
||||
This function reverses the bit order of the given value.
|
||||
|
||||
\param [in] value Value to reverse
|
||||
\return Reversed value
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
/** \brief LDR Exclusive (8 bit)
|
||||
|
||||
This function performs a exclusive LDR command for 8 bit value.
|
||||
|
||||
\param [in] ptr Pointer to data
|
||||
\return value of type uint8_t at (*ptr)
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE uint8_t __LDREXB(volatile uint8_t *addr)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
|
||||
__ASM volatile ("ldrexb %0, %1" : "=r" (result) : "Q" (*addr) );
|
||||
#else
|
||||
/* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
|
||||
accepted by assembler. So has to use following less efficient pattern.
|
||||
*/
|
||||
__ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) : "memory" );
|
||||
#endif
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
/** \brief LDR Exclusive (16 bit)
|
||||
|
||||
This function performs a exclusive LDR command for 16 bit values.
|
||||
|
||||
\param [in] ptr Pointer to data
|
||||
\return value of type uint16_t at (*ptr)
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE uint16_t __LDREXH(volatile uint16_t *addr)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
|
||||
__ASM volatile ("ldrexh %0, %1" : "=r" (result) : "Q" (*addr) );
|
||||
#else
|
||||
/* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
|
||||
accepted by assembler. So has to use following less efficient pattern.
|
||||
*/
|
||||
__ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) : "memory" );
|
||||
#endif
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
/** \brief LDR Exclusive (32 bit)
|
||||
|
||||
This function performs a exclusive LDR command for 32 bit values.
|
||||
|
||||
\param [in] ptr Pointer to data
|
||||
\return value of type uint32_t at (*ptr)
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __LDREXW(volatile uint32_t *addr)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__ASM volatile ("ldrex %0, %1" : "=r" (result) : "Q" (*addr) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
/** \brief STR Exclusive (8 bit)
|
||||
|
||||
This function performs a exclusive STR command for 8 bit values.
|
||||
|
||||
\param [in] value Value to store
|
||||
\param [in] ptr Pointer to location
|
||||
\return 0 Function succeeded
|
||||
\return 1 Function failed
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __STREXB(uint8_t value, volatile uint8_t *addr)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__ASM volatile ("strexb %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
/** \brief STR Exclusive (16 bit)
|
||||
|
||||
This function performs a exclusive STR command for 16 bit values.
|
||||
|
||||
\param [in] value Value to store
|
||||
\param [in] ptr Pointer to location
|
||||
\return 0 Function succeeded
|
||||
\return 1 Function failed
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __STREXH(uint16_t value, volatile uint16_t *addr)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__ASM volatile ("strexh %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
/** \brief STR Exclusive (32 bit)
|
||||
|
||||
This function performs a exclusive STR command for 32 bit values.
|
||||
|
||||
\param [in] value Value to store
|
||||
\param [in] ptr Pointer to location
|
||||
\return 0 Function succeeded
|
||||
\return 1 Function failed
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __STREXW(uint32_t value, volatile uint32_t *addr)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__ASM volatile ("strex %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
/** \brief Remove the exclusive lock
|
||||
|
||||
This function removes the exclusive lock which is created by LDREX.
|
||||
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE void __CLREX(void)
|
||||
{
|
||||
__ASM volatile ("clrex" ::: "memory");
|
||||
}
|
||||
|
||||
|
||||
/** \brief Signed Saturate
|
||||
|
||||
This function saturates a signed value.
|
||||
|
||||
\param [in] value Value to be saturated
|
||||
\param [in] sat Bit position to saturate to (1..32)
|
||||
\return Saturated value
|
||||
*/
|
||||
#define __SSAT(ARG1,ARG2) \
|
||||
({ \
|
||||
uint32_t __RES, __ARG1 = (ARG1); \
|
||||
__ASM ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
|
||||
__RES; \
|
||||
})
|
||||
|
||||
|
||||
/** \brief Unsigned Saturate
|
||||
|
||||
This function saturates an unsigned value.
|
||||
|
||||
\param [in] value Value to be saturated
|
||||
\param [in] sat Bit position to saturate to (0..31)
|
||||
\return Saturated value
|
||||
*/
|
||||
#define __USAT(ARG1,ARG2) \
|
||||
({ \
|
||||
uint32_t __RES, __ARG1 = (ARG1); \
|
||||
__ASM ("usat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
|
||||
__RES; \
|
||||
})
|
||||
|
||||
|
||||
/** \brief Count leading zeros
|
||||
|
||||
This function counts the number of leading zeros of a data value.
|
||||
|
||||
\param [in] value Value to count the leading zeros
|
||||
\return number of leading zeros in value
|
||||
*/
|
||||
__attribute__( ( always_inline ) ) __STATIC_INLINE uint8_t __CLZ(uint32_t value)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__ASM volatile ("clz %0, %1" : "=r" (result) : "r" (value) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
#endif /* (__CORTEX_M >= 0x03) */
|
||||
|
||||
|
||||
|
||||
|
||||
#elif defined ( __TASKING__ ) /*------------------ TASKING Compiler --------------*/
|
||||
/* TASKING carm specific functions */
|
||||
|
||||
/*
|
||||
* The CMSIS functions have been implemented as intrinsics in the compiler.
|
||||
* Please use "carm -?i" to get an up to date list of all intrinsics,
|
||||
* Including the CMSIS ones.
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
/*@}*/ /* end of group CMSIS_Core_InstructionInterface */
|
||||
|
||||
#endif /* __CORE_CMINSTR_H */
|
||||
|
|
@ -0,0 +1 @@
|
|||
app_start.c +
|
||||
|
|
@ -0,0 +1,265 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
//#include "build_info.h"
|
||||
#include "rtl8195a.h"
|
||||
#ifdef PLATFORM_FREERTOS
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "platform_stdlib.h"
|
||||
// #include "rtl_lib.h"
|
||||
#endif
|
||||
|
||||
#if defined (CONFIG_USB_EN) && defined(CONFIG_USB_HOST_ONLY)
|
||||
extern void _usb_init(void);
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SDIO_DEVICE_EN) && defined(CONFIG_SDIO_DEVICE_NORMAL)
|
||||
extern void HalSdioInit(void);
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_WIFI_NORMAL) && defined(CONFIG_NETWORK)
|
||||
extern void init_rom_wlan_ram_map(void);
|
||||
extern void wlan_network(void);
|
||||
#endif
|
||||
|
||||
//3 Monitor App Function
|
||||
extern void RtlConsolInitRam(uint32_t Boot, uint32_t TBLSz, void *pTBL);
|
||||
#ifndef CONFIG_KERNEL
|
||||
extern void RtlConsolTaskRom(void *Data);
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_WITHOUT_MONITOR
|
||||
extern COMMAND_TABLE UartLogRamCmdTable[];
|
||||
extern uint32_t GetRamCmdNum(void);
|
||||
extern void UartLogIrqHandleRam(void * Data);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_APP_DEMO
|
||||
#define MAIN_APP_DEFAULT_STACK_SIZE 2048
|
||||
#define MAIN_APP_DEFAULT_PRIORITY (tskIDLE_PRIORITY + 1)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MBED_ENABLED
|
||||
extern void __libc_fini_array (void);
|
||||
extern void __libc_init_array (void);
|
||||
extern void SVC_Handler (void);
|
||||
extern void PendSV_Handler (void);
|
||||
extern void SysTick_Handler (void);
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_WITHOUT_MONITOR
|
||||
static
|
||||
void
|
||||
ReRegisterPlatformLogUart(
|
||||
void
|
||||
)
|
||||
{
|
||||
IRQ_HANDLE UartIrqHandle;
|
||||
|
||||
//4 Register Log Uart Callback function
|
||||
UartIrqHandle.Data = (uint32_t)NULL;//(uint32_t)&UartAdapter;
|
||||
UartIrqHandle.IrqNum = UART_LOG_IRQ;
|
||||
UartIrqHandle.IrqFun = (IRQ_FUN) UartLogIrqHandleRam;
|
||||
UartIrqHandle.Priority = 5;
|
||||
|
||||
|
||||
//4 Register Isr handle
|
||||
InterruptUnRegister(&UartIrqHandle);
|
||||
InterruptRegister(&UartIrqHandle);
|
||||
#if !TASK_SCHEDULER_DISABLED
|
||||
RtlConsolInitRam((uint32_t)RAM_STAGE,(uint32_t)GetRamCmdNum(),(void*)&UartLogRamCmdTable);
|
||||
#else
|
||||
//RtlConsolInit(ROM_STAGE,GetRomCmdNum(),(void*)&UartLogRomCmdTable);// executing boot seq.,
|
||||
//pUartLogCtl->TaskRdy = 1;
|
||||
RtlConsolInitRam((uint32_t)ROM_STAGE,(uint32_t)GetRamCmdNum(),(void*)&UartLogRamCmdTable);
|
||||
#endif
|
||||
}
|
||||
#endif // end of "#ifndef CONFIG_WITHOUT_MONITOR"
|
||||
|
||||
|
||||
void ShowRamBuildInfo(void)
|
||||
{
|
||||
/*
|
||||
DBG_8195A("=========================================================\n\n");
|
||||
//DBG_8195A("Build Time: "UTS_VERSION"\n");
|
||||
DBG_8195A("Build Time: "RTL8195AFW_COMPILE_TIME"\n");
|
||||
DBG_8195A("Build Author: "RTL8195AFW_COMPILE_BY"\n");
|
||||
DBG_8195A("Build Host: "RTL8195AFW_COMPILE_HOST"\n");
|
||||
DBG_8195A("Build ToolChain Version: "RTL195AFW_COMPILER"\n\n");
|
||||
DBG_8195A("=========================================================\n");
|
||||
*/
|
||||
}
|
||||
|
||||
#if 1 //def CONFIG_APP_DEMO
|
||||
#include "rtl8195a.h"
|
||||
//#include "device.h"
|
||||
//#include "gpio_api.h" // mbed
|
||||
typedef struct _UART_LOG_BUF_ {
|
||||
uint8_t BufCount; //record the input cmd char number.
|
||||
uint8_t UARTLogBuf[127]; //record the input command.
|
||||
} UART_LOG_BUF, *PUART_LOG_BUF;
|
||||
|
||||
//MON_RAM_BSS_SECTION
|
||||
typedef struct _UART_LOG_CTL_ {
|
||||
uint8_t NewIdx; //+0
|
||||
uint8_t SeeIdx; //+1
|
||||
uint8_t RevdNo; //+2
|
||||
uint8_t EscSTS; //+3
|
||||
uint8_t ExecuteCmd; //+4
|
||||
uint8_t ExecuteEsc; //+5
|
||||
uint8_t BootRdy; //+6
|
||||
uint8_t Resvd; //+7
|
||||
PUART_LOG_BUF pTmpLogBuf;
|
||||
void *pfINPUT;
|
||||
PCOMMAND_TABLE pCmdTbl;
|
||||
uint32_t CmdTblSz;
|
||||
|
||||
uint32_t CRSTS;
|
||||
|
||||
uint8_t (*pHistoryBuf)[127];
|
||||
|
||||
uint32_t TaskRdy;
|
||||
uint32_t Sema;
|
||||
} UART_LOG_CTL, *PUART_LOG_CTL;
|
||||
|
||||
extern volatile UART_LOG_CTL *pUartLogCtl;
|
||||
|
||||
_WEAK int main(void)
|
||||
{
|
||||
HalPinCtrlRtl8195A(JTAG, 0, 1);
|
||||
|
||||
DiagPrintf("\r\nRTL Console ROM: Start - press key 'Up', Help '?'\r\n");
|
||||
while(pUartLogCtl->ExecuteEsc != 1);
|
||||
pUartLogCtl->RevdNo = 0;
|
||||
pUartLogCtl->BootRdy = 1;
|
||||
DiagPrintf("\r<RTL871xAx>");
|
||||
while(1) {
|
||||
while(pUartLogCtl->ExecuteCmd != 1 );
|
||||
UartLogCmdExecute(pUartLogCtl);
|
||||
DiagPrintf("\r<RTL871xAx>");
|
||||
pUartLogCtl->ExecuteCmd = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
//default main
|
||||
_WEAK int main(void)
|
||||
{
|
||||
// Init SDIO
|
||||
#if defined(CONFIG_SDIO_DEVICE_EN) && defined(CONFIG_SDIO_DEVICE_NORMAL)
|
||||
HalSdioInit();
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_WITHOUT_MONITOR
|
||||
ReRegisterPlatformLogUart();
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_WIFI_NORMAL) && defined(CONFIG_NETWORK)
|
||||
wlan_network();
|
||||
#else
|
||||
|
||||
#if defined (CONFIG_USB_EN) && defined(CONFIG_USB_HOST_ONLY)
|
||||
_usb_init();
|
||||
#endif
|
||||
|
||||
#endif // end of else of "#if defined(CONFIG_WIFI_NORMAL) && defined(CONFIG_NETWORK)"
|
||||
|
||||
//3 4)Enable Schedule
|
||||
#if defined(CONFIG_KERNEL) && !TASK_SCHEDULER_DISABLED
|
||||
#ifdef PLATFORM_FREERTOS
|
||||
vTaskStartScheduler();
|
||||
#endif
|
||||
#else
|
||||
RtlConsolTaskRom(NULL);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
#endif // end of #if CONFIG_APP_DEMO
|
||||
|
||||
__weak void __low_level_init(void)
|
||||
{
|
||||
// weak function
|
||||
}
|
||||
|
||||
#if defined ( __ICCARM__ )
|
||||
#pragma section="SDRAM.bss"
|
||||
#pragma section="SDRAM.bss"
|
||||
#endif
|
||||
// The Main App entry point
|
||||
void _AppStart(void)
|
||||
{
|
||||
#ifdef CONFIG_MBED_ENABLED
|
||||
InterruptForOSInit((void*)SVC_Handler,
|
||||
(void*)PendSV_Handler,
|
||||
(void*)SysTick_Handler);
|
||||
__asm (
|
||||
"ldr r0, =SystemInit\n"
|
||||
"blx r0\n"
|
||||
"ldr r0, =_start\n"
|
||||
"bx r0\n"
|
||||
);
|
||||
|
||||
for(;;);
|
||||
#else
|
||||
// It's Not Mbed BSP
|
||||
#ifdef CONFIG_KERNEL
|
||||
#endif
|
||||
|
||||
// Disable debug info log of spiflash
|
||||
DBG_INFO_MSG_OFF(_DBG_SPI_FLASH_);
|
||||
|
||||
#ifdef CONFIG_APP_DEMO
|
||||
#ifdef PLATFORM_FREERTOS
|
||||
xTaskCreate( (TaskFunction_t)main, "MAIN_APP__TASK", (MAIN_APP_DEFAULT_STACK_SIZE/4), (void *)NULL, MAIN_APP_DEFAULT_PRIORITY, NULL);
|
||||
vTaskStartScheduler();
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
__low_level_init();
|
||||
#if defined ( __ICCARM__ )
|
||||
// __iar_data_init3 replaced by __iar_cstart_call_ctors, just do c++ constructor,
|
||||
__iar_cstart_call_ctors(NULL);
|
||||
#ifdef CONFIG_SDR_EN
|
||||
// clear SDRAM bss
|
||||
uint8_t* __sdram_bss_start__ = (uint8_t*)__section_begin("SDRAM.bss");
|
||||
uint8_t* __sdram_bss_end__ = (uint8_t*)__section_end("SDRAM.bss");
|
||||
//DiagPrintf("clean sdram bss %8x to %8x\n\r", __sdram_bss_start__, __sdram_bss_end__);
|
||||
if((int)__sdram_bss_end__-(int)__sdram_bss_start__ > 0)
|
||||
memset(__sdram_bss_start__, 0, (int)__sdram_bss_end__-(int)__sdram_bss_start__);
|
||||
#endif
|
||||
#elif defined ( __GNUC__ )
|
||||
#ifdef CONFIG_SDR_EN
|
||||
// clear SDRAM bss
|
||||
extern uint8_t __sdram_bss_start__[];
|
||||
extern uint8_t __sdram_bss_end__[];
|
||||
//DiagPrintf("clean sdram bss %8x to %8x\n\r", __sdram_bss_start__, __sdram_bss_end__);
|
||||
if((int)__sdram_bss_end__-(int)__sdram_bss_start__ > 0)
|
||||
memset(__sdram_bss_start__, 0, (int)__sdram_bss_end__-(int)__sdram_bss_start__);
|
||||
#endif
|
||||
#else
|
||||
#error !!!!!!NOT Support this compiler!!!!!!
|
||||
#endif
|
||||
// force SP align to 8 byte not 4 byte (initial SP is 4 byte align)
|
||||
__asm(
|
||||
"mov r0, sp\n"
|
||||
"bic r0, r0, #7\n"
|
||||
"mov sp, r0\n"
|
||||
);
|
||||
|
||||
main();
|
||||
#if defined ( __ICCARM__ )
|
||||
// for compile issue, If user never call this function, Liking fail
|
||||
__iar_data_init3();
|
||||
#endif
|
||||
#endif // end of #if CONFIG_APP_DEMO
|
||||
|
||||
#endif // end of else of "#ifdef CONFIG_MBED_ENABLED"
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/* mbed Microcontroller Library
|
||||
* A generic CMSIS include header
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2014, STMicroelectronics
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef MBED_CMSIS_H
|
||||
#define MBED_CMSIS_H
|
||||
|
||||
#include "rtl8195a.h"
|
||||
#include "cmsis_nvic.h"
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
/* mbed Microcontroller Library
|
||||
* CMSIS-style functionality to support dynamic vectors
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2014, STMicroelectronics
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include "cmsis_nvic.h"
|
||||
|
||||
#define NVIC_RAM_VECTOR_ADDRESS (0x10000000) // Vectors positioned at start of RAM
|
||||
#define NVIC_ROM_VECTOR_ADDRESS (0x00000000) // Initial vector position at start of ROM
|
||||
|
||||
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
|
||||
uint32_t *vectors = (uint32_t *)SCB->VTOR;
|
||||
uint32_t i;
|
||||
|
||||
// Copy and switch to dynamic vectors if the first time called
|
||||
if (SCB->VTOR != NVIC_RAM_VECTOR_ADDRESS) {
|
||||
uint32_t *old_vectors = vectors;
|
||||
vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
|
||||
for (i=0; i<NVIC_NUM_VECTORS; i++) {
|
||||
vectors[i] = old_vectors[i];
|
||||
}
|
||||
SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS;
|
||||
}
|
||||
vectors[IRQn + NVIC_USER_IRQ_OFFSET] = vector;
|
||||
}
|
||||
|
||||
uint32_t NVIC_GetVector(IRQn_Type IRQn) {
|
||||
uint32_t *vectors = (uint32_t*)SCB->VTOR;
|
||||
return vectors[IRQn + NVIC_USER_IRQ_OFFSET];
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
/* mbed Microcontroller Library
|
||||
* CMSIS-style functionality to support dynamic vectors
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2014, STMicroelectronics
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef MBED_CMSIS_NVIC_H
|
||||
#define MBED_CMSIS_NVIC_H
|
||||
|
||||
// CORE: 64 vectors = 64 bytes from 0x00 to 0x3F
|
||||
// MCU Peripherals: 85 vectors = 340 bytes from 0x40 to ...
|
||||
// Total: 128 vectors = 512 bytes (0x200) to be reserved in RAM
|
||||
#define NVIC_NUM_VECTORS 128
|
||||
#define NVIC_USER_IRQ_OFFSET 64
|
||||
|
||||
#include "cmsis.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector);
|
||||
uint32_t NVIC_GetVector(IRQn_Type IRQn);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,888 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _DIAG_H_
|
||||
#define _DIAG_H_
|
||||
|
||||
#include "basic_types.h"
|
||||
#include "platform_autoconf.h"
|
||||
|
||||
#include <stddef.h> /* for size_t */
|
||||
|
||||
extern uint32_t ConfigDebugErr;
|
||||
extern uint32_t ConfigDebugInfo;
|
||||
extern uint32_t ConfigDebugWarn;
|
||||
|
||||
extern uint32_t CfgSysDebugErr;
|
||||
extern uint32_t CfgSysDebugInfo;
|
||||
extern uint32_t CfgSysDebugWarn;
|
||||
|
||||
#define DBG_ERR_MSG_ON(x) (ConfigDebugErr |= (x))
|
||||
#define DBG_WARN_MSG_ON(x) (ConfigDebugWarn |= (x))
|
||||
#define DBG_INFO_MSG_ON(x) (ConfigDebugInfo |= (x))
|
||||
|
||||
#define DBG_ERR_MSG_OFF(x) (ConfigDebugErr &= ~(x))
|
||||
#define DBG_WARN_MSG_OFF(x) (ConfigDebugWarn &= ~(x))
|
||||
#define DBG_INFO_MSG_OFF(x) (ConfigDebugInfo &= ~(x))
|
||||
|
||||
// Define debug group
|
||||
#define _DBG_BOOT_ 0x00000001
|
||||
#define _DBG_GDMA_ 0x00000002
|
||||
#define _DBG_GPIO_ 0x00000004
|
||||
#define _DBG_TIMER_ 0x00000008
|
||||
#define _DBG_I2C_ 0x00000010
|
||||
#define _DBG_I2S_ 0x00000020
|
||||
#define _DBG_MII_ 0x00000040
|
||||
#define _DBG_NFC_ 0x00000080
|
||||
#define _DBG_PCM_ 0x00000100
|
||||
#define _DBG_PWM_ 0x00000200
|
||||
#define _DBG_SDIO_ 0x00000400
|
||||
#define _DBG_SSI_ 0x00000800
|
||||
#define _DBG_SPI_FLASH_ 0x00001000
|
||||
#define _DBG_SDR_ 0x00002000
|
||||
#define _DBG_UART_ 0x00004000
|
||||
#define _DBG_USB_OTG_ 0x00008000
|
||||
#define _DBG_USB_CORE_ 0x00010000
|
||||
#define _DBG_CRYPTO_ 0x00020000
|
||||
#define _DBG_ADC_ 0x00040000
|
||||
#define _DBG_DAC_ 0x00080000
|
||||
#define _DBG_TCM_HEAP_ 0x00100000
|
||||
#define _DBG_RAM_HEAP_ 0x00200000
|
||||
#define _DBG_FEEP_ 0x00400000
|
||||
|
||||
#define _DBG_MISC_ 0x40000000
|
||||
#define _DBG_FAULT_ 0x80000000
|
||||
|
||||
typedef enum _SYSTEM_DBG_DEFINE_ {
|
||||
_SYSDBG_MISC_ = 1<<0,
|
||||
_SYSDBG_MAILBOX_ = 1<<1,
|
||||
_SYSDBG_TIMER_ = 1<<2
|
||||
|
||||
} SYSTEM_DBG;
|
||||
|
||||
extern
|
||||
_LONG_CALL_ROM_ uint32_t
|
||||
DiagPrintf(
|
||||
IN const char *fmt, ...
|
||||
);
|
||||
|
||||
uint32_t
|
||||
DiagSPrintf(
|
||||
IN uint8_t *buf,
|
||||
IN const char *fmt, ...
|
||||
);
|
||||
|
||||
int
|
||||
prvDiagPrintf(
|
||||
IN const char *fmt, ...
|
||||
);
|
||||
|
||||
int
|
||||
prvDiagSPrintf(
|
||||
IN char *buf,
|
||||
IN const char *fmt, ...
|
||||
);
|
||||
|
||||
extern char print_off;
|
||||
|
||||
#if CONFIG_DEBUG_LOG > 3
|
||||
#define debug_printf(fmt, ...) rtl_printf(fmt, ##__VA_ARGS__)
|
||||
#define info_printf(fmt, ...) rtl_printf(fmt, ##__VA_ARGS__)
|
||||
#define warning_printf(fmt, ...) rtl_printf(fmt, ##__VA_ARGS__)
|
||||
#define error_printf(fmt, ...) rtl_printf(fmt, ##__VA_ARGS__)
|
||||
#elif CONFIG_DEBUG_LOG > 2
|
||||
#define debug_printf(fmt, ...)
|
||||
#define info_printf(fmt, ...) rtl_printf(fmt, ##__VA_ARGS__)
|
||||
#define warning_printf(fmt, ...) rtl_printf(fmt, ##__VA_ARGS__)
|
||||
#define error_printf(fmt, ...) rtl_printf(fmt, ##__VA_ARGS__)
|
||||
#elif CONFIG_DEBUG_LOG > 1
|
||||
#define debug_printf(fmt, ...)
|
||||
#define info_printf(fmt, ...)
|
||||
#define warning_printf(fmt, ...) rtl_printf(fmt, ##__VA_ARGS__)
|
||||
#define error_printf(fmt, ...) rtl_printf(fmt, ##__VA_ARGS__)
|
||||
#elif CONFIG_DEBUG_LOG > 0
|
||||
#define debug_printf(fmt, ...)
|
||||
#define info_printf(fmt, ...)
|
||||
#define warning_printf(fmt, ...)
|
||||
#define error_printf(fmt, ...) rtl_printf(fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
#define debug_printf(fmt, ...)
|
||||
#define info_printf(fmt, ...)
|
||||
#define warning_printf(fmt, ...)
|
||||
#define error_printf(fmt, ...)
|
||||
#endif
|
||||
|
||||
#define _DbgDump DiagPrintf
|
||||
|
||||
#define DRIVER_PREFIX "RTL8195A[Driver]: "
|
||||
#define HAL_PREFIX "RTL8195A[HAL]: "
|
||||
#define DMA_PREFIX "RTL8195A[DMA]: "
|
||||
#define SDIO_PREFIX "RTL8195A[SDIO]"
|
||||
#define MBOX_PREFIX "[OS-MBOX]"
|
||||
#define TIMER_PREFIX "[OS-TMR]"
|
||||
|
||||
#define BOOT_ERR_PREFIX "[BOOT Err]"
|
||||
#define BOOT_WARN_PREFIX "[BOOT Wrn]"
|
||||
#define BOOT_INFO_PREFIX "[BOOT Inf]"
|
||||
|
||||
#define GDMA_ERR_PREFIX "[GDMA Err]"
|
||||
#define GDMA_WARN_PREFIX "[GDMA Wrn]"
|
||||
#define GDMA_INFO_PREFIX "[GDMA Inf]"
|
||||
|
||||
#define GPIO_ERR_PREFIX "[GPIO Err]"
|
||||
#define GPIO_WARN_PREFIX "[GPIO Wrn]"
|
||||
#define GPIO_INFO_PREFIX "[GPIO Inf]"
|
||||
|
||||
#define TIMER_ERR_PREFIX "[TIMR Err]"
|
||||
#define TIMER_WARN_PREFIX "[TIMR Wrn]"
|
||||
#define TIMER_INFO_PREFIX "[TIMR Inf]"
|
||||
|
||||
#define I2C_ERR_PREFIX "[I2C Err]"
|
||||
#define I2C_WARN_PREFIX "[I2C Wrn]"
|
||||
#define I2C_INFO_PREFIX "[I2C Inf]"
|
||||
|
||||
#define I2S_ERR_PREFIX "[I2S Err]"
|
||||
#define I2S_WARN_PREFIX "[I2S Wrn]"
|
||||
#define I2S_INFO_PREFIX "[I2S Inf]"
|
||||
|
||||
#define MII_ERR_PREFIX "[MII Err]"
|
||||
#define MII_WARN_PREFIX "[MII Wrn]"
|
||||
#define MII_INFO_PREFIX "[MII Inf]"
|
||||
|
||||
#define NFC_ERR_PREFIX "[NFC Err]"
|
||||
#define NFC_WARN_PREFIX "[NFC Wrn]"
|
||||
#define NFC_INFO_PREFIX "[NFC Inf]"
|
||||
|
||||
#define PCM_ERR_PREFIX "[PCM Err]"
|
||||
#define PCM_WARN_PREFIX "[PCM Wrn]"
|
||||
#define PCM_INFO_PREFIX "[PCM Inf]"
|
||||
|
||||
#define PWM_ERR_PREFIX "[PWM Err]"
|
||||
#define PWM_WARN_PREFIX "[PWM Wrn]"
|
||||
#define PWM_INFO_PREFIX "[PWM Inf]"
|
||||
|
||||
#define SSI_ERR_PREFIX "[SSI Err]"
|
||||
#define SSI_WARN_PREFIX "[SSI Wrn]"
|
||||
#define SSI_INFO_PREFIX "[SSI Inf]"
|
||||
|
||||
#define SDIO_ERR_PREFIX "[SDIO Err]"
|
||||
#define SDIO_WARN_PREFIX "[SDIO Wrn]"
|
||||
#define SDIO_INFO_PREFIX "[SDIO Inf]"
|
||||
|
||||
#define SPIF_ERR_PREFIX "[SPIF Err]"
|
||||
#define SPIF_WARN_PREFIX "[SPIF Wrn]"
|
||||
#define SPIF_INFO_PREFIX "[SPIF Inf]"
|
||||
|
||||
#define SDR_ERR_PREFIX "[SDR Err]"
|
||||
#define SDR_WARN_PREFIX "[SDR Wrn]"
|
||||
#define SDR_INFO_PREFIX "[SDR Inf]"
|
||||
|
||||
#define UART_ERR_PREFIX "[UART Err]"
|
||||
#define UART_WARN_PREFIX "[UART Wrn]"
|
||||
#define UART_INFO_PREFIX "[UART Inf]"
|
||||
|
||||
#define USB_ERR_PREFIX "[USB Err]"
|
||||
#define USB_WARN_PREFIX "[USB Wrn]"
|
||||
#define USB_INFO_PREFIX "[USB Inf]"
|
||||
|
||||
#define IPSEC_ERR_PREFIX "[CRYP Err]"
|
||||
#define IPSEC_WARN_PREFIX "[CRYP Wrn]"
|
||||
#define IPSEC_INFO_PREFIX "[CRYP Inf]"
|
||||
|
||||
#define ADC_ERR_PREFIX "[ADC Err]"
|
||||
#define ADC_WARN_PREFIX "[ADC Wrn]"
|
||||
#define ADC_INFO_PREFIX "[ADC Inf]"
|
||||
|
||||
#define DAC_ERR_PREFIX "[DAC Err]"
|
||||
#define DAC_WARN_PREFIX "[DAC Wrn]"
|
||||
#define DAC_INFO_PREFIX "[DAC Inf]"
|
||||
|
||||
#define MISC_ERR_PREFIX "[MISC Err]"
|
||||
#define MISC_WARN_PREFIX "[MISC Wrn]"
|
||||
#define MISC_INFO_PREFIX "[MISC Inf]"
|
||||
|
||||
#define OTG_ERR_PREFIX "[OTG Err]"
|
||||
#define OTG_WARN_PREFIX "[OTG Wrn]"
|
||||
#define OTG_INFO_PREFIX "[OTG Inf]"
|
||||
|
||||
#define HEAP_ERR_PREFIX "[HEAP Err]"
|
||||
#define HEAP_WARN_PREFIX "[HEAP Wrn]"
|
||||
#define HEAP_INFO_PREFIX "[HEAP Inf]"
|
||||
|
||||
#define FEEP_ERR_PREFIX "[FEEP Err]"
|
||||
#define FEEP_WARN_PREFIX "[FEEP Wrn]"
|
||||
#define FEEP_INFO_PREFIX "[FEEP Inf]"
|
||||
|
||||
#define OTG_PREFIX "RTL8195A[OTG]: "
|
||||
#define OTG_PREFIX_LVL "RTL8195A[OTG_LVL_%2x]: "
|
||||
|
||||
#ifdef CONFIG_DEBUG_LOG
|
||||
#if CONFIG_DEBUG_LOG > 2
|
||||
#define CONFIG_DEBUG_ERROR 1
|
||||
#define CONFIG_DEBUG_WARN 1
|
||||
#define CONFIG_DEBUG_INFO 1
|
||||
#elif CONFIG_DEBUG_LOG > 1
|
||||
#define CONFIG_DEBUG_ERROR 1
|
||||
#define CONFIG_DEBUG_WARN 1
|
||||
#elif CONFIG_DEBUG_LOG > 0
|
||||
#define CONFIG_DEBUG_ERROR 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef likely
|
||||
#define likely(x) (x)
|
||||
#define unlikely(x) (x)
|
||||
#endif
|
||||
|
||||
|
||||
#if CONFIG_DEBUG_ERROR // if Build-In Debug Error Message
|
||||
|
||||
#define DBG_BOOT_ERR(...) do {\
|
||||
if (likely(ConfigDebugErr & _DBG_BOOT_)) \
|
||||
_DbgDump(BOOT_ERR_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_GDMA_ERR(...) do {\
|
||||
if (likely(ConfigDebugErr & _DBG_GDMA_)) \
|
||||
_DbgDump(GDMA_ERR_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_GPIO_ERR(...) do {\
|
||||
if (likely(ConfigDebugErr & _DBG_GPIO_)) \
|
||||
_DbgDump(GPIO_ERR_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_TIMER_ERR(...) do {\
|
||||
if (likely(ConfigDebugErr & _DBG_TIMER_)) \
|
||||
_DbgDump(TIMER_ERR_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_I2C_ERR(...) do {\
|
||||
if (likely(ConfigDebugErr & _DBG_I2C_)) \
|
||||
_DbgDump(I2C_ERR_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_I2S_ERR(...) do {\
|
||||
if (likely(ConfigDebugErr & _DBG_I2S_)) \
|
||||
_DbgDump(I2S_ERR_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_MII_ERR(...) do {\
|
||||
if (likely(ConfigDebugErr & _DBG_MII_)) \
|
||||
_DbgDump(MII_ERR_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_NFC_ERR(...) do {\
|
||||
if (likely(ConfigDebugErr & _DBG_NFC_)) \
|
||||
_DbgDump(NFC_ERR_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_PCM_ERR(...) do {\
|
||||
if (likely(ConfigDebugErr & _DBG_PCM_)) \
|
||||
_DbgDump(PCM_ERR_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_PWM_ERR(...) do {\
|
||||
if (likely(ConfigDebugErr & _DBG_PWM_)) \
|
||||
_DbgDump(PWM_ERR_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_SSI_ERR(...) do {\
|
||||
if (likely(ConfigDebugErr & _DBG_SSI_)) \
|
||||
_DbgDump(SSI_ERR_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_SDIO_ERR(...) do {\
|
||||
if (likely(ConfigDebugErr & _DBG_SDIO_)) \
|
||||
_DbgDump(SDIO_ERR_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_SPIF_ERR(...) do {\
|
||||
if (likely(ConfigDebugErr & _DBG_SPI_FLASH_)) \
|
||||
_DbgDump(SPIF_ERR_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_SDR_ERR(...) do {\
|
||||
if (likely(ConfigDebugErr & _DBG_SDR_)) \
|
||||
_DbgDump(SDR_ERR_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_UART_ERR(...) do {\
|
||||
if (likely(ConfigDebugErr & _DBG_UART_)) \
|
||||
_DbgDump(UART_ERR_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_USBOTG_ERR(...) do {\
|
||||
if (likely(ConfigDebugErr & _DBG_USB_OTG_)) \
|
||||
_DbgDump( __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_USBCOR_ERR(...) do {\
|
||||
if (likely(ConfigDebugErr & _DBG_USB_CORE_)) \
|
||||
_DbgDump(USB_ERR_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_CRYPTO_ERR(...) do {\
|
||||
if (likely(ConfigDebugErr & _DBG_CRYPTO_)) \
|
||||
_DbgDump(IPSEC_ERR_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_ADC_ERR(...) do {\
|
||||
if (likely(ConfigDebugErr & _DBG_ADC_)) \
|
||||
_DbgDump(ADC_ERR_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_DAC_ERR(...) do {\
|
||||
if (likely(ConfigDebugErr & _DBG_DAC_)) \
|
||||
_DbgDump(DAC_ERR_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define MSG_MBOX_ERR(...) do {\
|
||||
if (likely(CfgSysDebugErr & _SYSDBG_MAILBOX_)) \
|
||||
_DbgDump(MBOX_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define MSG_TIMER_ERR(...) do {\
|
||||
if (likely(CfgSysDebugErr & _SYSDBG_TIMER_)) \
|
||||
_DbgDump(TIMER_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_8195A_OTG(...) do{\
|
||||
if (unlikely(ConfigDebugInfo & _DBG_USB_OTG_)) \
|
||||
_DbgDump(OTG_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_8195A_OTG_INFO(...) do{\
|
||||
if (unlikely(ConfigDebugInfo & _DBG_USB_OTG_)) \
|
||||
_DbgDump(OTG_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_8195A_OTG_WARN(...) do{\
|
||||
if (unlikely(ConfigDebugWarn & _DBG_USB_OTG_)) \
|
||||
_DbgDump(OTG_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_8195A_OTG_ERR(...) do{\
|
||||
if (unlikely(ConfigDebugErr & _DBG_USB_OTG_)) \
|
||||
_DbgDump(OTG_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_8195A_OTG_LVL(LVL,...) do{\
|
||||
if (unlikely(ConfigDebugInfo & _DBG_USB_OTG_)){ \
|
||||
_DbgDump(OTG_PREFIX_LVL,LVL);\
|
||||
_DbgDump(__VA_ARGS__);\
|
||||
}\
|
||||
}while(0)
|
||||
|
||||
#define DBG_TCM_HEAP_ERR(...) do {\
|
||||
if (likely(ConfigDebugErr & _DBG_TCM_HEAP_)){ \
|
||||
_DbgDump(HEAP_ERR_PREFIX ANSI_COLOR_RED);\
|
||||
_DbgDump(__VA_ARGS__ );\
|
||||
_DbgDump(ANSI_COLOR_RESET);}\
|
||||
}while(0)
|
||||
|
||||
#define DBG_RAM_HEAP_ERR(...) do {\
|
||||
if (likely(ConfigDebugErr & _DBG_RAM_HEAP_)){ \
|
||||
_DbgDump(HEAP_ERR_PREFIX ANSI_COLOR_RED);\
|
||||
_DbgDump(__VA_ARGS__ );\
|
||||
_DbgDump(ANSI_COLOR_RESET);}\
|
||||
}while(0)
|
||||
|
||||
#define DBG_MISC_ERR(...) do {\
|
||||
if (likely(ConfigDebugErr & _DBG_MISC_)) \
|
||||
_DbgDump(MISC_ERR_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_FEEP_ERR(...) do {\
|
||||
if (likely(ConfigDebugErr & _DBG_FEEP_)) \
|
||||
_DbgDump(FEEP_ERR_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
|
||||
#else // else of "#if CONFIG_DEBUG_ERROR"
|
||||
|
||||
#define DBG_BOOT_ERR(...)
|
||||
#define DBG_GDMA_ERR(...)
|
||||
#define DBG_GPIO_ERR(...)
|
||||
#define DBG_TIMER_ERR(...)
|
||||
#define DBG_I2C_ERR(...)
|
||||
#define DBG_I2S_ERR(...)
|
||||
#define DBG_MII_ERR(...)
|
||||
#define DBG_NFC_ERR(...)
|
||||
#define DBG_PCM_ERR(...)
|
||||
#define DBG_PWM_ERR(...)
|
||||
#define DBG_SSI_ERR(...)
|
||||
#define DBG_SDIO_ERR(...)
|
||||
#define DBG_SPIF_ERR(...)
|
||||
#define DBG_SDR_ERR(...)
|
||||
#define DBG_UART_ERR(...)
|
||||
#define DBG_USBOTG_ERR(...)
|
||||
#define DBG_USBCOR_ERR(...)
|
||||
#define DBG_CRYPTO_ERR(...)
|
||||
#define DBG_ADC_ERR(...)
|
||||
#define DBG_DAC_ERR(...)
|
||||
|
||||
#define MSG_MBOX_ERR(...)
|
||||
#define MSG_TIMER_ERR(...)
|
||||
#define DBG_8195A_OTG(...)
|
||||
#define DBG_8195A_OTG_LVL(LVL,...)
|
||||
#define DBG_8195A_OTG_INFO(...)
|
||||
#define DBG_8195A_OTG_WARN(...)
|
||||
#define DBG_8195A_OTG_ERR(...)
|
||||
|
||||
#define DBG_TCM_HEAP_ERR(...)
|
||||
#define DBG_RAM_HEAP_ERR(...)
|
||||
#define DBG_FEEP_ERR(...)
|
||||
#define DBG_MISC_ERR(...)
|
||||
|
||||
#endif // end of else of "#if CONFIG_DEBUG_ERROR"
|
||||
|
||||
// =============================================================
|
||||
|
||||
#if CONFIG_DEBUG_WARN // if Build-In Debug Warring Message
|
||||
|
||||
#define DBG_BOOT_WARN(...) do {\
|
||||
if (unlikely(ConfigDebugWarn& _DBG_BOOT_)) \
|
||||
_DbgDump(BOOT_WARN_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_GDMA_WARN(...) do {\
|
||||
if (unlikely(ConfigDebugWarn & _DBG_GDMA_)) \
|
||||
_DbgDump(GDMA_WARN_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_GPIO_WARN(...) do {\
|
||||
if (unlikely(ConfigDebugWarn & _DBG_GPIO_)) \
|
||||
_DbgDump(GPIO_WARN_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_TIMER_WARN(...) do {\
|
||||
if (unlikely(ConfigDebugWarn & _DBG_TIMER_)) \
|
||||
_DbgDump(TIMER_WARN_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_I2C_WARN(...) do {\
|
||||
if (unlikely(ConfigDebugWarn & _DBG_I2C_)) \
|
||||
_DbgDump(I2C_WARN_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_I2S_WARN(...) do {\
|
||||
if (unlikely(ConfigDebugWarn & _DBG_I2S_)) \
|
||||
_DbgDump(I2S_WARN_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_MII_WARN(...) do {\
|
||||
if (unlikely(ConfigDebugWarn & _DBG_MII_)) \
|
||||
_DbgDump(MII_WARN_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_NFC_WARN(...) do {\
|
||||
if (unlikely(ConfigDebugWarn & _DBG_NFC_)) \
|
||||
_DbgDump(NFC_WARN_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_PCM_WARN(...) do {\
|
||||
if (unlikely(ConfigDebugWarn & _DBG_PCM_)) \
|
||||
_DbgDump(PCM_WARN_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_PWM_WARN(...) do {\
|
||||
if (unlikely(ConfigDebugWarn & _DBG_PWM_)) \
|
||||
_DbgDump(PWM_WARN_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_SSI_WARN(...) do {\
|
||||
if (unlikely(ConfigDebugWarn & _DBG_SSI_)) \
|
||||
_DbgDump(SSI_WARN_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_SDIO_WARN(...) do {\
|
||||
if (unlikely(ConfigDebugWarn & _DBG_SDIO_)) \
|
||||
_DbgDump(SDIO_WARN_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_SPIF_WARN(...) do {\
|
||||
if (unlikely(ConfigDebugWarn & _DBG_SPI_FLASH_)) \
|
||||
_DbgDump(SPIF_WARN_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_SDR_WARN(...) do {\
|
||||
if (unlikely(ConfigDebugWarn & _DBG_SDR_)) \
|
||||
_DbgDump(SDR_WARN_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_UART_WARN(...) do {\
|
||||
if (unlikely(ConfigDebugWarn & _DBG_UART_)) \
|
||||
_DbgDump(UART_WARN_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_USBOTG_WARN(...) do {\
|
||||
if (unlikely(ConfigDebugWarn & _DBG_USB_OTG_)) \
|
||||
_DbgDump( __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_USBCOR_WARN(...) do {\
|
||||
if (unlikely(ConfigDebugWarn & _DBG_USB_CORE_)) \
|
||||
_DbgDump(USB_WARN_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_CRYPTO_WARN(...) do {\
|
||||
if (unlikely(ConfigDebugWarn & _DBG_CRYPTO_)) \
|
||||
_DbgDump(IPSEC_WARN_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_ADC_WARN(...) do {\
|
||||
if (unlikely(ConfigDebugWarn & _DBG_ADC_)) \
|
||||
_DbgDump(ADC_WARN_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_DAC_WARN(...) do {\
|
||||
if (unlikely(ConfigDebugWarn & _DBG_DAC_)) \
|
||||
_DbgDump(DAC_WARN_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define MSG_MBOX_WARN(...) do {\
|
||||
if (unlikely(CfgSysDebugWarn& _SYSDBG_MAILBOX_)) \
|
||||
_DbgDump(MBOX_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define MSG_TIMER_WARN(...) do {\
|
||||
if (unlikely(CfgSysDebugWarn & _SYSDBG_TIMER_)) \
|
||||
_DbgDump(TIMER_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_TCM_HEAP_WARN(...) do {\
|
||||
if (likely(ConfigDebugWarn & _DBG_TCM_HEAP_)){ \
|
||||
_DbgDump(HEAP_WARN_PREFIX ANSI_COLOR_MAGENTA);\
|
||||
_DbgDump(__VA_ARGS__ );\
|
||||
_DbgDump(ANSI_COLOR_RESET);}\
|
||||
}while(0)
|
||||
|
||||
#define DBG_RAM_HEAP_WARN(...) do {\
|
||||
if (likely(ConfigDebugWarn & _DBG_RAM_HEAP_)){ \
|
||||
_DbgDump(HEAP_WARN_PREFIX ANSI_COLOR_MAGENTA);\
|
||||
_DbgDump(__VA_ARGS__ );\
|
||||
_DbgDump(ANSI_COLOR_RESET);}\
|
||||
}while(0)
|
||||
|
||||
#define DBG_FEEP_WARN(...) do {\
|
||||
if (likely(ConfigDebugWarn & _DBG_FEEP_)) \
|
||||
_DbgDump(FEEP_WARN_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_MISC_WARN(...) do {\
|
||||
if (likely(ConfigDebugWarn & _DBG_MISC_)) \
|
||||
_DbgDump(MISC_WARN_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#else // else of "#if CONFIG_DEBUG_WARN"
|
||||
|
||||
#define DBG_BOOT_WARN(...)
|
||||
#define DBG_GDMA_WARN(...)
|
||||
#define DBG_GPIO_WARN(...)
|
||||
#define DBG_TIMER_WARN(...)
|
||||
#define DBG_I2C_WARN(...)
|
||||
#define DBG_I2S_WARN(...)
|
||||
#define DBG_MII_WARN(...)
|
||||
#define DBG_NFC_WARN(...)
|
||||
#define DBG_PCM_WARN(...)
|
||||
#define DBG_PWM_WARN(...)
|
||||
#define DBG_SSI_WARN(...)
|
||||
#define DBG_SDIO_WARN(...)
|
||||
#define DBG_SPIF_WARN(...)
|
||||
#define DBG_SDR_WARN(...)
|
||||
#define DBG_UART_WARN(...)
|
||||
#define DBG_USBOTG_WARN(...)
|
||||
#define DBG_USBCOR_WARN(...)
|
||||
#define DBG_CRYPTO_WARN(...)
|
||||
#define DBG_ADC_WARN(...)
|
||||
#define DBG_DAC_WARN(...)
|
||||
#define DBG_TCM_HEAP_WARN(...)
|
||||
#define DBG_RAM_HEAP_WARN(...)
|
||||
#define DBG_FEEP_WARN(...)
|
||||
#define DBG_MISC_WARN(...)
|
||||
|
||||
#define MSG_MBOX_WARN(...)
|
||||
#define MSG_TIMER_WARN(...)
|
||||
|
||||
#endif // end of else of "#if CONFIG_DEBUG_WARN"
|
||||
|
||||
// =============================================================
|
||||
|
||||
#if CONFIG_DEBUG_INFO // if Build-In Debug Information Message
|
||||
|
||||
#define DBG_BOOT_INFO(...) do {\
|
||||
if (unlikely(ConfigDebugInfo & _DBG_BOOT_)) \
|
||||
_DbgDump(BOOT_INFO_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_GDMA_INFO(...) do {\
|
||||
if (unlikely(ConfigDebugInfo & _DBG_GDMA_)) \
|
||||
_DbgDump(GDMA_INFO_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_GPIO_INFO(...) do {\
|
||||
if (unlikely(ConfigDebugInfo & _DBG_GPIO_)) \
|
||||
_DbgDump(GPIO_INFO_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_TIMER_INFO(...) do {\
|
||||
if (unlikely(ConfigDebugInfo & _DBG_TIMER_)) \
|
||||
_DbgDump(TIMER_INFO_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_I2C_INFO(...) do {\
|
||||
if (unlikely(ConfigDebugInfo & _DBG_I2C_)) \
|
||||
_DbgDump(I2C_INFO_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_I2S_INFO(...) do {\
|
||||
if (unlikely(ConfigDebugInfo & _DBG_I2S_)) \
|
||||
_DbgDump(I2S_INFO_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_MII_INFO(...) do {\
|
||||
if (unlikely(ConfigDebugInfo & _DBG_MII_)) \
|
||||
_DbgDump(MII_INFO_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_NFC_INFO(...) do {\
|
||||
if (unlikely(ConfigDebugInfo & _DBG_NFC_)) \
|
||||
_DbgDump(NFC_INFO_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_PCM_INFO(...) do {\
|
||||
if (unlikely(ConfigDebugInfo & _DBG_PCM_)) \
|
||||
_DbgDump(PCM_INFO_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_PWM_INFO(...) do {\
|
||||
if (unlikely(ConfigDebugInfo & _DBG_PWM_)) \
|
||||
_DbgDump(PWM_INFO_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_SSI_INFO(...) do {\
|
||||
if (unlikely(ConfigDebugInfo & _DBG_SSI_)) \
|
||||
_DbgDump(SSI_INFO_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_SDIO_INFO(...) do {\
|
||||
if (unlikely(ConfigDebugInfo & _DBG_SDIO_)) \
|
||||
_DbgDump(SDIO_INFO_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_SPIF_INFO(...) do {\
|
||||
if (unlikely(ConfigDebugInfo & _DBG_SPI_FLASH_)) \
|
||||
_DbgDump(SPIF_INFO_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_SDR_INFO(...) do {\
|
||||
if (unlikely(ConfigDebugInfo & _DBG_SDR_)) \
|
||||
_DbgDump(SDR_INFO_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_UART_INFO(...) do {\
|
||||
if (unlikely(ConfigDebugInfo & _DBG_UART_)) \
|
||||
_DbgDump(UART_INFO_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_USBOTG_INFO(...) do {\
|
||||
if (unlikely(ConfigDebugInfo & _DBG_USB_OTG_)) \
|
||||
_DbgDump( __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_USBCOR_INFO(...) do {\
|
||||
if (unlikely(ConfigDebugInfo & _DBG_USB_CORE_)) \
|
||||
_DbgDump(USB_INFO_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_CRYPTO_INFO(...) do {\
|
||||
if (unlikely(ConfigDebugInfo & _DBG_CRYPTO_)) \
|
||||
_DbgDump(IPSEC_INFO_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_ADC_INFO(...) do {\
|
||||
if (unlikely(ConfigDebugInfo & _DBG_ADC_)) \
|
||||
_DbgDump(ADC_INFO_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_DAC_INFO(...) do {\
|
||||
if (unlikely(ConfigDebugInfo & _DBG_DAC_)) \
|
||||
_DbgDump(DAC_INFO_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define MSG_MBOX_INFO(...) do {\
|
||||
if (unlikely(CfgSysDebugInfo & _SYSDBG_MAILBOX_)) \
|
||||
_DbgDump(MBOX_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define MSG_TIMER_INFO(...) do {\
|
||||
if (unlikely(CfgSysDebugInfo & _SYSDBG_TIMER_)) \
|
||||
_DbgDump(TIMER_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_TCM_HEAP_INFO(...) do {\
|
||||
if (likely(ConfigDebugInfo & _DBG_TCM_HEAP_)){\
|
||||
_DbgDump(HEAP_INFO_PREFIX ANSI_COLOR_BLUE);\
|
||||
_DbgDump(__VA_ARGS__ );\
|
||||
_DbgDump(ANSI_COLOR_RESET);}\
|
||||
}while(0)
|
||||
|
||||
#define DBG_RAM_HEAP_INFO(...) do {\
|
||||
if (likely(ConfigDebugInfo & _DBG_RAM_HEAP_)){ \
|
||||
_DbgDump(HEAP_INFO_PREFIX ANSI_COLOR_BLUE);\
|
||||
_DbgDump(__VA_ARGS__ );\
|
||||
_DbgDump(ANSI_COLOR_RESET);}\
|
||||
}while(0)
|
||||
|
||||
#define DBG_FEEP_INFO(...) do {\
|
||||
if (unlikely(ConfigDebugInfo & _DBG_FEEP_)) \
|
||||
_DbgDump(FEEP_INFO_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_MISC_INFO(...) do {\
|
||||
if (likely(ConfigDebugInfo & _DBG_MISC_)) \
|
||||
_DbgDump(MISC_INFO_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#else // else of "#if CONFIG_DEBUG_INFO"
|
||||
|
||||
#define DBG_BOOT_INFO(...)
|
||||
#define DBG_GDMA_INFO(...)
|
||||
#define DBG_GPIO_INFO(...)
|
||||
#define DBG_TIMER_INFO(...)
|
||||
#define DBG_I2C_INFO(...)
|
||||
#define DBG_I2S_INFO(...)
|
||||
#define DBG_MII_INFO(...)
|
||||
#define DBG_NFC_INFO(...)
|
||||
#define DBG_PCM_INFO(...)
|
||||
#define DBG_PWM_INFO(...)
|
||||
#define DBG_SSI_INFO(...)
|
||||
#define DBG_SDIO_INFO(...)
|
||||
#define DBG_SPIF_INFO(...)
|
||||
#define DBG_SDR_INFO(...)
|
||||
#define DBG_UART_INFO(...)
|
||||
#define DBG_USBOTG_INFO(...)
|
||||
#define DBG_USBCOR_INFO(...)
|
||||
#define DBG_CRYPTO_INFO(...)
|
||||
#define DBG_ADC_INFO(...)
|
||||
#define DBG_DAC_INFO(...)
|
||||
#define DBG_RAM_HEAP_INFO(...)
|
||||
#define DBG_TCM_HEAP_INFO(...)
|
||||
#define DBG_FEEP_INFO(...)
|
||||
#define DBG_MISC_INFO(...)
|
||||
|
||||
#define MSG_MBOX_INFO(...)
|
||||
#define MSG_TIMER_INFO(...)
|
||||
|
||||
#endif // end of else of "#if CONFIG_DEBUG_INFO"
|
||||
|
||||
// =============================================================
|
||||
|
||||
#ifdef CONFIG_DEBUG_LOG
|
||||
|
||||
#define DBG_8195A_DRIVER(...) do {\
|
||||
if (unlikely(ConfigDebugErr & (_DBG_I2S_|_DBG_PCM_|_DBG_TIMER_))) \
|
||||
_DbgDump(DRIVER_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_8195A_HAL(...) do {\
|
||||
if (unlikely(ConfigDebugErr & (_DBG_SDR_|_DBG_MISC_))) \
|
||||
_DbgDump(HAL_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_8195A_DMA(...) do {\
|
||||
if (unlikely(ConfigDebugErr & _DBG_GDMA_)) \
|
||||
_DbgDump(DMA_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_8195A_SDIO(...) do {\
|
||||
if (unlikely(ConfigDebugErr & _DBG_SDIO_)) \
|
||||
_DbgDump(SDIO_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_8195A(...) do {\
|
||||
if (unlikely(ConfigDebugErr & _DBG_MISC_)) \
|
||||
_DbgDump( __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define MONITOR_LOG(...) do {\
|
||||
if (unlikely(ConfigDebugErr & _DBG_MISC_)) \
|
||||
_DbgDump( __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_ERROR_LOG(...) do {\
|
||||
if (unlikely(ConfigDebugErr & _DBG_FAULT_)) \
|
||||
_DbgDump( __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define DBG_ASSERT(x) do {\
|
||||
if (unlikely(!(x))) \
|
||||
_DbgDump("Assertion: %s:%s, %d\n", __FILE__, __func__, __LINE__);\
|
||||
}while(0)
|
||||
#endif
|
||||
|
||||
#ifdef __ICCARM__
|
||||
#define DBG_ASSERT(x) do {\
|
||||
if (unlikely(!(x))) \
|
||||
_DbgDump("Assertion: %s:%s, %d\n", __FILE__, __func__, __LINE__);\
|
||||
}while(0)
|
||||
#endif
|
||||
|
||||
#else // #ifdef CONFIG_DEBUG_LOG
|
||||
|
||||
#define DBG_8195A_DRIVER(...)
|
||||
#define DBG_8195A_HAL(...)
|
||||
#define DBG_8195A_DMA(...)
|
||||
#define DBG_8195A_SDIO(...)
|
||||
#define DBG_8195A(...)
|
||||
#define MONITOR_LOG(...)
|
||||
#define DBG_ERROR_LOG(...)
|
||||
#define DBG_ASSERT(...)
|
||||
|
||||
#endif // #ifdef CONFIG_DEBUG_LOG
|
||||
|
||||
// =============================================================
|
||||
|
||||
#define ANSI_COLOR_GREEN "\x1b[32m"
|
||||
#define ANSI_COLOR_CYAN "\x1b[36m"
|
||||
#define ANSI_COLOR_YELLOW "\x1b[33m"
|
||||
#define ANSI_COLOR_MAGENTA "\x1b[35m"
|
||||
#define ANSI_COLOR_RED "\x1b[31m"
|
||||
#define ANSI_COLOR_BLUE "\x1b[34m"
|
||||
#define ANSI_COLOR_RESET "\x1b[0m"
|
||||
|
||||
#define IDENT_ONE_SPACE " "
|
||||
#define IDENT_TWO_SPACE " "
|
||||
#define IDENT_FOUR_SPACE " "
|
||||
#define IDENT_SIX_SPACE " "
|
||||
#define IDENT_EIGHT_SPACE " "
|
||||
|
||||
// =============================================================
|
||||
|
||||
#ifdef CONFIG_DEBUG_LOG
|
||||
typedef enum _DBG_CFG_TYPE_ {
|
||||
DBG_CFG_ERR=0,
|
||||
DBG_CFG_WARN=1,
|
||||
DBG_CFG_INFO=2
|
||||
} DBG_CFG_TYPE;
|
||||
|
||||
typedef struct _DBG_CFG_CMD_ {
|
||||
uint8_t cmd_name[16];
|
||||
uint32_t cmd_type;
|
||||
} DBG_CFG_CMD, *PDBG_CFG_CMD;
|
||||
#endif // #ifdef CONFIG_DEBUG_LOG
|
||||
|
||||
typedef enum _CONSOLE_OP_STAGE_ {
|
||||
ROM_STAGE = 0,
|
||||
RAM_STAGE = 1
|
||||
}CONSOLE_OP_STAGE;
|
||||
|
||||
#endif //_DIAG_H_
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
uint32_t
|
||||
Rand (
|
||||
void
|
||||
);
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Routines for standard lib access
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _RTL_STDLIB_H_
|
||||
#define _RTL_STDLIB_H_
|
||||
#if 0
|
||||
#include <basic_types.h>
|
||||
#include <strproc.h>
|
||||
#include <diag.h>
|
||||
|
||||
//
|
||||
// string operation
|
||||
//
|
||||
#define strlen(str) prvStrLen((const uint8_t*)str)
|
||||
#define strcmp(str1, str2) prvStrCmp((const uint8_t*)str1, (const uint8_t*)str2)
|
||||
//#define sscanf(src, format...) //TODO: Strtoul(src,0,16) / Strtoul(src,0,10)
|
||||
#define strtok(str, delim) prvStrTok(str, delim)
|
||||
#define strcpy(dst, src) prvStrCpy((uint8_t *)dst, (const uint8_t*)src)
|
||||
#define atoi(str) prvAtoi(str)
|
||||
#define strstr(str1, str2) prvStrStr(str1, str2)
|
||||
|
||||
//
|
||||
// standard i/o
|
||||
//
|
||||
#define snprintf DiagSnPrintf
|
||||
#define sprintf prvDiagSPrintf
|
||||
#define printf prvDiagPrintf
|
||||
|
||||
//
|
||||
// memory management
|
||||
//
|
||||
#define malloc pvPortMalloc
|
||||
#define free vPortFree
|
||||
#endif
|
||||
#endif //_RTL_STDLIB_H_
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
|
||||
*
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef __RTL_UTILITY_H_
|
||||
#define __RTL_UTILITY_H_
|
||||
|
||||
void RtlMemcpy(void* dec, void* sour, uint32_t sz);
|
||||
uint32_t RtlMemcmp(void *dst, void *src, uint32_t sz);
|
||||
void RtlMemset(void *pbuf, uint32_t c, uint32_t sz);
|
||||
|
||||
int8_t *
|
||||
RtlStrncpy(
|
||||
IN int8_t *dest,
|
||||
IN const int8_t *src,
|
||||
IN SIZE_T count
|
||||
);
|
||||
|
||||
int8_t *
|
||||
RtlStrcpy(
|
||||
IN int8_t *dest,
|
||||
IN const int8_t *src
|
||||
);
|
||||
|
||||
|
||||
SIZE_T
|
||||
RtlStrlen(
|
||||
IN const int8_t *s
|
||||
);
|
||||
|
||||
|
||||
SIZE_T
|
||||
RtlStrnlen(
|
||||
IN const int8_t *s,
|
||||
IN SIZE_T count
|
||||
);
|
||||
|
||||
|
||||
int
|
||||
RtlStrcmp(
|
||||
IN const int8_t *cs,
|
||||
IN const int8_t *ct
|
||||
|
||||
);
|
||||
|
||||
int
|
||||
RtlStrncmp(
|
||||
IN const int8_t *cs,
|
||||
IN const int8_t *ct,
|
||||
IN SIZE_T count
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _STRPROC_H_
|
||||
#define _STRPROC_H_
|
||||
|
||||
#include <stddef.h> /* for size_t */
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifndef isprint
|
||||
#define in_range(c, lo, up) ((uint8_t)c >= lo && (uint8_t)c <= up)
|
||||
#define isprint(c) in_range(c, 0x20, 0x7f)
|
||||
#define isdigit(c) in_range(c, '0', '9')
|
||||
#define isxdigit(c) (isdigit(c) || in_range(c, 'a', 'f') || in_range(c, 'A', 'F'))
|
||||
#define islower(c) in_range(c, 'a', 'z')
|
||||
#define isspace(c) (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v' || c == ',')
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER // IntelliSense
|
||||
#define _LONG_CALL_ROM_
|
||||
#endif
|
||||
|
||||
extern _LONG_CALL_ROM_ char *_strncpy(char *dest, const char *src, size_t count);
|
||||
extern _LONG_CALL_ROM_ char *_strcpy(char *dest, const char *src);
|
||||
extern _LONG_CALL_ROM_ size_t _strlen(const char *s);
|
||||
extern _LONG_CALL_ROM_ size_t _strnlen(const char *s, size_t count);
|
||||
extern _LONG_CALL_ROM_ int _strcmp(const char *cs, const char *ct);
|
||||
extern _LONG_CALL_ROM_ int _strncmp(const char *cs, const char *ct, size_t count);
|
||||
extern _LONG_CALL_ROM_ int _sscanf(const char *buf, const char *fmt, ...);
|
||||
extern _LONG_CALL_ROM_ char *_strsep(char **s, const char *ct);
|
||||
extern _LONG_CALL_ROM_ char *skip_spaces(const char *str);
|
||||
extern _LONG_CALL_ROM_ int skip_atoi(const char **s);
|
||||
extern _LONG_CALL_ROM_ int _vsscanf(const char *buf, const char *fmt, va_list args);
|
||||
extern _LONG_CALL_ROM_ unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base);
|
||||
extern _LONG_CALL_ROM_ long simple_strtol(const char *cp, char **endp, unsigned int base);
|
||||
extern _LONG_CALL_ROM_ long long simple_strtoll(const char *cp, char **endp, unsigned int base);
|
||||
extern _LONG_CALL_ROM_ unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base);
|
||||
extern _LONG_CALL_ROM_ const char *_parse_integer_fixup_radix(const char *s, unsigned int *base);
|
||||
extern _LONG_CALL_ROM_ unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long *p);
|
||||
extern _LONG_CALL_ROM_ uint64_t div_u64(uint64_t dividend, uint32_t divisor);
|
||||
extern _LONG_CALL_ROM_ int64_t div_s64(int64_t dividend, int32_t divisor);
|
||||
extern _LONG_CALL_ROM_ uint64_t div_u64_rem(uint64_t dividend, uint32_t divisor, uint32_t *remainder);
|
||||
extern _LONG_CALL_ROM_ int64_t div_s64_rem(int64_t dividend, int32_t divisor, int32_t *remainder);
|
||||
extern _LONG_CALL_ROM_ char *_strpbrk(const char *cs, const char *ct);
|
||||
extern _LONG_CALL_ROM_ char *_strchr(const char *s, int c);
|
||||
|
||||
|
||||
extern _LONG_CALL_ROM_ void
|
||||
prvStrCpy(
|
||||
IN uint8_t *pDES,
|
||||
IN const uint8_t *pSRC
|
||||
);
|
||||
|
||||
extern _LONG_CALL_ROM_ uint32_t
|
||||
prvStrLen(
|
||||
IN const uint8_t *pSRC
|
||||
);
|
||||
|
||||
extern _LONG_CALL_ROM_ uint8_t
|
||||
prvStrCmp(
|
||||
IN const uint8_t *string1,
|
||||
IN const uint8_t *string2
|
||||
);
|
||||
|
||||
extern _LONG_CALL_ROM_ uint8_t*
|
||||
StrUpr(
|
||||
IN uint8_t *string
|
||||
);
|
||||
|
||||
extern _LONG_CALL_ROM_ int prvAtoi(
|
||||
IN const char * s
|
||||
);
|
||||
|
||||
extern _LONG_CALL_ROM_ const char * prvStrStr(
|
||||
IN const char * str1,
|
||||
IN const char * str2
|
||||
);
|
||||
|
||||
#ifndef __GNUC__
|
||||
/*
|
||||
* Fast implementation of tolower() for internal usage. Do not use in your
|
||||
* code.
|
||||
*/
|
||||
static inline char _tolower(const char c)
|
||||
{
|
||||
return c | 0x20;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Fast check for octal digit */
|
||||
static inline int isodigit(const char c)
|
||||
{
|
||||
return c >= '0' && c <= '7';
|
||||
}
|
||||
#ifndef strtoul
|
||||
#define strtoul(str, endp, base) simple_strtoul(str, endp, base)
|
||||
#endif
|
||||
#ifndef strtol
|
||||
#define strtol(str, endp, base) simple_strtol(str, endp, base)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,142 @@
|
|||
/**************************************************************************//**
|
||||
* @file system_ARMCM3.c
|
||||
* @brief CMSIS Device System Source File for
|
||||
* ARMCM3 Device Series
|
||||
* @version V1.08
|
||||
* @date 23. November 2012
|
||||
*
|
||||
* @note
|
||||
*
|
||||
******************************************************************************/
|
||||
/* Copyright (c) 2011 - 2012 ARM LIMITED
|
||||
|
||||
All rights reserved.
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
- Neither the name of ARM nor the names of its contributors may be used
|
||||
to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
*
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include "platform_autoconf.h"
|
||||
#include "basic_types.h"
|
||||
#include "rtl8195a.h"
|
||||
#include "rtl_bios_data.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Define clocks
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define __HSI ( 8000000UL)
|
||||
#define __XTAL ( 5000000UL) /* Oscillator frequency */
|
||||
|
||||
//#define __SYSTEM_CLOCK (5*__XTAL)
|
||||
//#define __SYSTEM_CLOCK (200000000UL/6*5) // PLATFORM_CLOCK in platform_autoconf.h ! //
|
||||
|
||||
//extern uint32_t HalGetCpuClk(void);
|
||||
|
||||
#ifdef CONFIG_CHIP_A_CUT
|
||||
const uint32_t SysCpkClkTbl[]= {
|
||||
200000000,
|
||||
100000000,
|
||||
50000000,
|
||||
25000000,
|
||||
12500000,
|
||||
4000000
|
||||
};
|
||||
#endif
|
||||
|
||||
//extern unsigned int rand_x = 12345;
|
||||
/*
|
||||
uint32_t Rand2(void)
|
||||
{
|
||||
static unsigned int y = 362436;
|
||||
static unsigned int z = 521288629;
|
||||
static unsigned int c = 7654321;
|
||||
|
||||
unsigned long long t, a= 698769069;
|
||||
|
||||
rand_x = 69069 * rand_x + 12345;
|
||||
y ^= (y << 13); y ^= (y >> 17); y ^= (y << 5);
|
||||
t = a * z + c; c = (t >> 32); z = t;
|
||||
|
||||
return rand_x + y + z;
|
||||
}
|
||||
*/
|
||||
/*----------------------------------------------------------------------------
|
||||
Clock Variable definitions
|
||||
*----------------------------------------------------------------------------*/
|
||||
uint32_t SystemCoreClock = PLATFORM_CLOCK; // __SYSTEM_CLOCK; /*!< System Clock Frequency (Core Clock)*/
|
||||
|
||||
|
||||
uint32_t
|
||||
SystemGetCpuClk(void)
|
||||
{
|
||||
#ifdef CONFIG_CHIP_A_CUT
|
||||
|
||||
uint32_t CpuType = 0, CpuClk = 0, FreqDown = 0;
|
||||
|
||||
CpuType = ((HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_CLK_CTRL1) & (0x70)) >> 4);
|
||||
FreqDown = HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_SYSPLL_CTRL1) & BIT17;
|
||||
|
||||
CpuClk = SysCpkClkTbl[CpuType];
|
||||
|
||||
if ( !FreqDown ) {
|
||||
if ( CpuClk > 4000000 ){
|
||||
CpuClk = (CpuClk*5/6);
|
||||
}
|
||||
}
|
||||
|
||||
return CpuClk;
|
||||
#else
|
||||
return HalGetCpuClk();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Clock functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
void SystemCoreClockUpdate (void) /* Get Core Clock Frequency */
|
||||
{
|
||||
// SystemCoreClock = __SYSTEM_CLOCK;
|
||||
|
||||
SystemCoreClock = SystemGetCpuClk();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the system
|
||||
*
|
||||
* @param none
|
||||
* @return none
|
||||
*
|
||||
* @brief Setup the microcontroller system.
|
||||
* Initialize the System.
|
||||
*/
|
||||
void SystemInit (void)
|
||||
{
|
||||
// TODO: Hardware initial
|
||||
#ifdef UNALIGNED_SUPPORT_DISABLE
|
||||
SCB->CCR |= SCB_CCR_UNALIGN_TRP_Msk;
|
||||
#endif
|
||||
|
||||
//SystemCoreClock = __SYSTEM_CLOCK;
|
||||
//SystemCoreClock = HalGetCpuClk();
|
||||
SystemCoreClockUpdate();
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
/**************************************************************************//**
|
||||
* @file system_ARMCM3.h
|
||||
* @brief CMSIS Device System Header File for
|
||||
* ARMCM3 Device Series
|
||||
* @version V1.08
|
||||
* @date 23. November 2012
|
||||
*
|
||||
* @note
|
||||
*
|
||||
******************************************************************************/
|
||||
/* Copyright (c) 2011 - 2012 ARM LIMITED
|
||||
|
||||
All rights reserved.
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
- Neither the name of ARM nor the names of its contributors may be used
|
||||
to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
*
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef _SYSTEM_8195A_H
|
||||
#define _SYSTEM_8195A_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the system
|
||||
*
|
||||
* @param none
|
||||
* @return none
|
||||
*
|
||||
* @brief Setup the microcontroller system.
|
||||
* Initialize the System and update the SystemCoreClock variable.
|
||||
*/
|
||||
extern void SystemInit (void);
|
||||
|
||||
/**
|
||||
* Update SystemCoreClock variable
|
||||
*
|
||||
* @param none
|
||||
* @return none
|
||||
*
|
||||
* @brief Updates the SystemCoreClock with current core Clock
|
||||
* retrieved from cpu registers.
|
||||
*/
|
||||
extern void SystemCoreClockUpdate (void);
|
||||
extern uint32_t SystemGetCpuClk(void);
|
||||
extern _LONG_CALL_ uint32_t Rand2(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SYSTEM_8195A_H */
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _VA_LIST_H_
|
||||
#define _VA_LIST_H_
|
||||
|
||||
#include "platform_autoconf.h"
|
||||
#include "basic_types.h"
|
||||
|
||||
#ifndef va_arg //this part is adapted from linux (Linux/include/acpi/platform/acenv.h)
|
||||
|
||||
typedef int32_t acpi_native_int;//this definition is in (Linux/include/acpi/actypes.h)
|
||||
|
||||
#ifndef _VALIST
|
||||
#define _VALIST
|
||||
typedef char *va_list;
|
||||
#endif /* _VALIST */
|
||||
|
||||
/* Storage alignment properties */
|
||||
#define _AUPBND (sizeof (acpi_native_int) - 1)
|
||||
#define _ADNBND (sizeof (acpi_native_int) - 1)
|
||||
|
||||
/* Variable argument list macro definitions */
|
||||
#define _bnd(X, bnd) (((sizeof (X)) + (bnd)) & (~(bnd)))
|
||||
#define va_arg(ap, T) (*(T *)(((ap) += (_bnd (T, _AUPBND))) - (_bnd (T,_ADNBND))))
|
||||
#define va_end(ap) (ap = (va_list) NULL)
|
||||
#define va_start(ap, A) (void) ((ap) = (((char *) &(A)) + (_bnd (A,_AUPBND))))
|
||||
|
||||
#endif /* va_arg */
|
||||
|
||||
#endif //_VA_LIST_H_
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
|
||||
#include "bitband_io.h"
|
||||
//#include "rtl8195a_gpio.h"
|
||||
|
||||
#define BITBAND_ADDR(a,b) (0x02000000 + (a & 0xF0000000) + (a - (a & 0xF0000000)) * 32 + ((b) * 4)) // Convert address ?
|
||||
|
||||
volatile uint8_t * BitBandAddr(void *addr, uint8_t bit) {
|
||||
uint32_t ret = BITBAND_ADDR((uint32_t)addr, bit);
|
||||
return (volatile uint8_t *) ret;
|
||||
}
|
||||
|
||||
volatile uint8_t * BitBandPeriAddr(void *addr, uint8_t bit) {
|
||||
return (volatile uint8_t *)(BITBAND_PERI((uint32_t)addr, bit));
|
||||
}
|
||||
|
||||
volatile uint8_t * GetOutPinBitBandAddr(PinName pin) {
|
||||
volatile uint8_t * paddr = 0;
|
||||
uint32_t ippin = HAL_GPIO_GetIPPinName_8195a(pin);
|
||||
if(ippin < 0xff) {
|
||||
// paddr = 0x42000000 + (0x40001000 + 0x0c * (ippin >> 5) - 0x40000000) * 32 + ((ippin & 0x1f) * 4);
|
||||
paddr = BitBandPeriAddr((void *)(GPIO_REG_BASE + GPIO_PORTB_DR * (ippin >> 5)), ippin & 0x1f);
|
||||
}
|
||||
return paddr;
|
||||
}
|
||||
|
||||
volatile uint8_t * GetInPinBitBandAddr(PinName pin) {
|
||||
volatile uint8_t * paddr = NULL;
|
||||
uint32_t ippin = HAL_GPIO_GetIPPinName_8195a(pin);
|
||||
if(ippin < 0xff) {
|
||||
// paddr = 0x42000000 + (0x40001000 + 0x0c * (ippin >> 5) - 0x40000000) * 32 + ((ippin & 0x1f) * 4);
|
||||
paddr = BitBandPeriAddr((void *)(GPIO_REG_BASE + GPIO_EXT_PORTA + (ippin >> 5) * 4), ippin & 0x1f);
|
||||
}
|
||||
return paddr;
|
||||
}
|
||||
|
||||
extern _LONG_CALL_ uint32_t GPIO_FuncOn_8195a(void);
|
||||
extern void wait_us(int us);
|
||||
|
||||
volatile uint8_t * HardSetPin(PinName pin, HAL_GPIO_PIN_MODE pmode, uint8_t val)
|
||||
{
|
||||
volatile uint8_t *paddr = NULL;
|
||||
uint32_t ippin = HAL_GPIO_GetIPPinName_8195a(pin);
|
||||
if(ippin < 0xff) {
|
||||
if(_pHAL_Gpio_Adapter == NULL) {
|
||||
extern HAL_GPIO_ADAPTER gBoot_Gpio_Adapter;
|
||||
_pHAL_Gpio_Adapter = &gBoot_Gpio_Adapter;
|
||||
}
|
||||
if(_pHAL_Gpio_Adapter->Gpio_Func_En == 0) GPIO_FuncOn_8195a();
|
||||
wait_us(100);
|
||||
// delayMicroseconds(100);
|
||||
// paddr = 0x42000000 + (0x40001000 + 0x0c * (ippin >> 5) - 0x40000000) * 32 + ((ippin & 0x1f) * 4);
|
||||
#if CONFIG_DEBUG_LOG > 3
|
||||
GpioFunctionChk(ippin, ENABLE);
|
||||
#endif
|
||||
GPIO_PullCtrl_8195a(ippin, HAL_GPIO_HIGHZ); // Make the pin pull control default as High-Z
|
||||
paddr = BitBandPeriAddr((void *)(GPIO_REG_BASE + GPIO_PORTB_DR * (ippin >> 5)), ippin & 0x1f);
|
||||
*paddr = val; // data register
|
||||
HAL_GPIO_PIN gpio;
|
||||
gpio.pin_name = ippin;
|
||||
gpio.pin_mode = pmode;
|
||||
HAL_GPIO_Init_8195a(&gpio);
|
||||
*paddr = val; // data register
|
||||
// paddr[(GPIO_PORTB_DDR - GPIO_PORTB_DR) * 32] = pmode == DOUT_PUSH_PULL; // data direction
|
||||
// GPIO_PullCtrl_8195a(ippin, pmode); // set GPIO_PULL_CTRLx
|
||||
// paddr[(GPIO_PORTB_CTRL - GPIO_PORTB_DR) * 32] = 0; // data source control, we should keep it as default: data source from software
|
||||
}
|
||||
return paddr;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,153 @@
|
|||
#ifndef _BITBAND_IO_H_
|
||||
#define _BITBAND_IO_H_
|
||||
|
||||
#include "PinNames.h"
|
||||
#include "hal_platform.h"
|
||||
#include "hal_api.h"
|
||||
#include "hal_gpio.h"
|
||||
#include "rtl8195a_gpio.h"
|
||||
|
||||
#define BITBAND_SRAM_REF 0x10000000
|
||||
#define BITBAND_SRAM_BASE 0x12000000
|
||||
#define BITBAND_SRAM(a,b) (BITBAND_SRAM_BASE + (a-BITBAND_SRAM_REF)*32 + (b*4)) // Convert SRAM address
|
||||
|
||||
/*
|
||||
* in hal_platform.h
|
||||
#define BITBAND_REG_BASE 0x40001000
|
||||
*/
|
||||
|
||||
/*
|
||||
* in rtl8195a_gpio.h
|
||||
*
|
||||
#define BITBAND_PORTA_DR 0x00 // data register
|
||||
#define BITBAND_PORTA_DDR 0x04 // data direction
|
||||
#define BITBAND_PORTA_CTRL 0x08 // data source control, we should keep it as default: data source from software
|
||||
|
||||
#define BITBAND_PORTB_DR 0x0c // data register
|
||||
#define BITBAND_PORTB_DDR 0x10 // data direction
|
||||
#define BITBAND_PORTB_CTRL 0x14 // data source control, we should keep it as default: data source from software
|
||||
|
||||
#define BITBAND_PORTC_DR 0x18 // data register
|
||||
#define BITBAND_PORTC_DDR 0x1c // data direction
|
||||
#define BITBAND_PORTC_CTRL 0x20 // data source control, we should keep it as default: data source from software
|
||||
|
||||
#define BITBAND_EXT_PORTA 0x50 // GPIO IN read or OUT read back
|
||||
#define BITBAND_EXT_PORTB 0x54 // GPIO IN read or OUT read back
|
||||
#define BITBAND_EXT_PORTC 0x58 // GPIO IN read or OUT read back
|
||||
*/
|
||||
|
||||
#define BITBAND_PERI_REF 0x40000000
|
||||
#define BITBAND_PERI_BASE 0x42000000
|
||||
#define BITBAND_PERI(a,b) (BITBAND_PERI_BASE + (a-BITBAND_PERI_REF)*32 + (b*4)) // Convert PERI address
|
||||
#define ucBITBAND_PERI(a,b) *((volatile unsigned char *)BITBAND_PERI(a,b))
|
||||
#define uiBITBAND_PERI(a,b) *((volatile unsigned int *)BITBAND_PERI(a,b))
|
||||
|
||||
#define BITBAND_A0 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,0) //Port = 0, bit = 0, A0
|
||||
#define BITBAND_A1 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,1) //Port = 0, bit = 1, A1
|
||||
#define BITBAND_A2 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTB_DR,0) //Port = 1, bit = 0, A2
|
||||
#define BITBAND_A3 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTB_DR,1) //Port = 1, bit = 1, A3
|
||||
#define BITBAND_A4 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTB_DR,2) //Port = 1, bit = 2, A4
|
||||
#define BITBAND_A5 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTB_DR,3) //Port = 1, bit = 3, A5
|
||||
#define BITBAND_A6 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTB_DR,4) //Port = 1, bit = 4, A6
|
||||
#define BITBAND_A7 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTB_DR,5) //Port = 1, bit = 5, A7
|
||||
|
||||
#define BITBAND_B0 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTB_DR,6) //Port = 1, bit = 6, B0
|
||||
#define BITBAND_B1 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTB_DR,7) //Port = 1, bit = 7, B1
|
||||
#define BITBAND_B2 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTB_DR,8) //Port = 1, bit = 8, B2
|
||||
#define BITBAND_B3 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,2) //Port = 0, bit = 2, B3
|
||||
#define BITBAND_B4 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,3) //Port = 0, bit = 3, B4
|
||||
#define BITBAND_B5 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTB_DR,9) //Port = 1, bit = 9, B5
|
||||
#define BITBAND_B6 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,4) //Port = 0, bit = 4, B6
|
||||
#define BITBAND_B7 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,5) //Port = 0, bit = 5, B7
|
||||
|
||||
#define BITBAND_C0 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTB_DR,10) //Port = 1, bit = 10, C0
|
||||
#define BITBAND_C1 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,6) //Port = 0, bit = 6, C1
|
||||
#define BITBAND_C2 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTB_DR,11) //Port = 1, bit = 11, C2
|
||||
#define BITBAND_C3 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,7) //Port = 0, bit = 7, C3
|
||||
#define BITBAND_C4 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,8) //Port = 0, bit = 8, C4
|
||||
#define BITBAND_C5 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,9) //Port = 0, bit = 9, C5
|
||||
#define BITBAND_C6 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,10) //Port = 0, bit = 10, C6
|
||||
#define BITBAND_C7 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,11) //Port = 0, bit = 11, C7
|
||||
#define BITBAND_C8 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,12) //Port = 0, bit = 12, C8
|
||||
#define BITBAND_C9 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,13) //Port = 0, bit = 13, C9
|
||||
|
||||
#define BITBAND_D0 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTB_DR,12) //Port = 1, bit = 12, D0
|
||||
#define BITBAND_D1 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,14) //Port = 0, bit = 14, D1
|
||||
#define BITBAND_D2 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTB_DR,13) //Port = 1, bit = 13, D2
|
||||
#define BITBAND_D3 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,15) //Port = 0, bit = 15, D3
|
||||
#define BITBAND_D4 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,16) //Port = 0, bit = 16, D4
|
||||
#define BITBAND_D5 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,17) //Port = 0, bit = 17, D5
|
||||
#define BITBAND_D6 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,18) //Port = 0, bit = 18, D6
|
||||
#define BITBAND_D7 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,19) //Port = 0, bit = 19, D7
|
||||
#define BITBAND_D8 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTB_DR,14) //Port = 1, bit = 14, D8
|
||||
#define BITBAND_D9 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,20) //Port = 0, bit = 20, D9
|
||||
|
||||
#define BITBAND_E0 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTC_DR,15) //Port = 2, bit = 15, E0
|
||||
#define BITBAND_E1 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,21) //Port = 0, bit = 21, E1
|
||||
#define BITBAND_E2 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,22) //Port = 0, bit = 22, E2
|
||||
#define BITBAND_E3 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,23) //Port = 0, bit = 23, E3
|
||||
#define BITBAND_E4 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTB_DR,16) //Port = 1, bit = 16, E4
|
||||
#define BITBAND_E5 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,24) //Port = 0, bit = 24, E5
|
||||
#define BITBAND_E6 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,25) //Port = 0, bit = 25, E6
|
||||
#define BITBAND_E7 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,26) //Port = 0, bit = 26, E7
|
||||
#define BITBAND_E8 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,27) //Port = 0, bit = 27, E8
|
||||
#define BITBAND_E9 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTB_DR,17) //Port = 1, bit = 17, E9
|
||||
#define BITBAND_E10 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTB_DR,18) //Port = 1, bit = 17, E10
|
||||
|
||||
#define BITBAND_F0 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTB_DR,19) //Port = 1, bit = 19, F0
|
||||
#define BITBAND_F1 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTB_DR,20) //Port = 1, bit = 20, F1
|
||||
#define BITBAND_F2 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTB_DR,21) //Port = 1, bit = 21, F2
|
||||
#define BITBAND_F3 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTB_DR,22) //Port = 1, bit = 22, F3
|
||||
#define BITBAND_F4 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTB_DR,23) //Port = 1, bit = 23, F4
|
||||
#define BITBAND_F5 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTB_DR,24) //Port = 1, bit = 24, F5
|
||||
|
||||
#define BITBAND_G0 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTB_DR,25) //Port = 1, bit = 25, G0
|
||||
#define BITBAND_G1 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTB_DR,26) //Port = 1, bit = 26, G1
|
||||
#define BITBAND_G2 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTB_DR,27) //Port = 1, bit = 27, G2
|
||||
#define BITBAND_G3 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,28) //Port = 0, bit = 28, G3
|
||||
#define BITBAND_G4 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTB_DR,28) //Port = 1, bit = 28, G4
|
||||
#define BITBAND_G5 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTB_DR,29) //Port = 1, bit = 29, G5
|
||||
#define BITBAND_G6 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTB_DR,30) //Port = 1, bit = 30, G6
|
||||
#define BITBAND_G7 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTB_DR,31) //Port = 1, bit = 31, G7
|
||||
|
||||
#define BITBAND_H0 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTC_DR,0) //Port = 2, bit = 0, H0
|
||||
#define BITBAND_H1 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,29) //Port = 0, bit = 29, H1
|
||||
#define BITBAND_H2 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTC_DR,1) //Port = 2, bit = 1, H2
|
||||
#define BITBAND_H3 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,30) //Port = 0, bit = 30, H3
|
||||
#define BITBAND_H4 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTC_DR,2) //Port = 2, bit = 2, H4
|
||||
#define BITBAND_H5 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,31) //Port = 0, bit = 31, H5
|
||||
#define BITBAND_H6 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTC_DR,3) //Port = 2, bit = 3, H6
|
||||
#define BITBAND_H7 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTA_DR,4) //Port = 2, bit = 4, H7
|
||||
|
||||
#define BITBAND_I0 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTC_DR,5) //Port = 2, bit = 5, I0
|
||||
#define BITBAND_I1 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTC_DR,6) //Port = 2, bit = 6, I1
|
||||
#define BITBAND_I2 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTC_DR,7) //Port = 2, bit = 7, I2
|
||||
#define BITBAND_I3 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTC_DR,8) //Port = 2, bit = 8, I3
|
||||
#define BITBAND_I4 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTC_DR,9) //Port = 2, bit = 9, I4
|
||||
#define BITBAND_I5 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTC_DR,10) //Port = 2, bit = 10, I5
|
||||
#define BITBAND_I6 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTC_DR,11) //Port = 2, bit = 11, I6
|
||||
#define BITBAND_I7 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTC_DR,12) //Port = 2, bit = 12, I7
|
||||
|
||||
#define BITBAND_J0 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTC_DR,13) //Port = 2, bit = 13, J0
|
||||
#define BITBAND_J1 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTC_DR,14) //Port = 2, bit = 14, J1
|
||||
#define BITBAND_J2 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTC_DR,15) //Port = 2, bit = 15, J2
|
||||
#define BITBAND_J3 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTC_DR,16) //Port = 2, bit = 16, J3
|
||||
#define BITBAND_J4 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTC_DR,17) //Port = 2, bit = 17, J4
|
||||
#define BITBAND_J5 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTC_DR,18) //Port = 2, bit = 18, J5
|
||||
#define BITBAND_J6 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTC_DR,19) //Port = 2, bit = 19, J6
|
||||
|
||||
#define BITBAND_K0 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTC_DR,20) //Port = 2, bit = 20, K0
|
||||
#define BITBAND_K1 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTC_DR,21) //Port = 2, bit = 21, K1
|
||||
#define BITBAND_K2 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTC_DR,22) //Port = 2, bit = 22, K2
|
||||
#define BITBAND_K3 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTC_DR,23) //Port = 2, bit = 23, K3
|
||||
#define BITBAND_K4 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTC_DR,24) //Port = 2, bit = 24, K4
|
||||
#define BITBAND_K5 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTC_DR,25) //Port = 2, bit = 25, K5
|
||||
#define BITBAND_K6 ucBITBAND_PERI(GPIO_REG_BASE+GPIO_PORTC_DR,26) //Port = 2, bit = 26, K6
|
||||
|
||||
volatile uint8_t * BitBandAddr(void *addr, uint8_t bit);
|
||||
volatile uint8_t * BitBandPeriAddr(void *addr, uint8_t bit);
|
||||
volatile uint8_t * GetOutPinBitBandAddr(PinName pin);
|
||||
volatile uint8_t * GetInPinBitBandAddr(PinName pin);
|
||||
volatile uint8_t * HardSetPin(PinName pin, HAL_GPIO_PIN_MODE pmode, uint8_t val);
|
||||
|
||||
#endif // _BITBAND_IO_H_
|
||||
305
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_32k.c
Normal file
305
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_32k.c
Normal file
|
|
@ -0,0 +1,305 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
|
||||
#include "rtl8195a.h"
|
||||
|
||||
#ifdef CONFIG_TIMER_MODULE
|
||||
|
||||
void
|
||||
En32KCalibration(
|
||||
void
|
||||
)
|
||||
{
|
||||
uint32_t Rtemp;
|
||||
uint32_t Ttemp = 0;
|
||||
#if CONFIG_DEBUG_LOG > 5
|
||||
DiagPrintf("32K clock source calibration\n");
|
||||
#endif
|
||||
//set parameter
|
||||
HAL_WRITE32(SYSTEM_CTRL_BASE,REG_OSC32K_REG_CTRL0, 0);
|
||||
//offset 1 = 0x1500
|
||||
Rtemp = 0x811500;
|
||||
HAL_WRITE32(SYSTEM_CTRL_BASE,REG_OSC32K_REG_CTRL0, Rtemp);
|
||||
HalDelayUs(40);
|
||||
HAL_WRITE32(SYSTEM_CTRL_BASE,REG_OSC32K_REG_CTRL0, 0);
|
||||
|
||||
//offset 2 = 0x01c0
|
||||
Rtemp = 0x8201c0;
|
||||
HAL_WRITE32(SYSTEM_CTRL_BASE,REG_OSC32K_REG_CTRL0, Rtemp);
|
||||
HalDelayUs(40);
|
||||
HAL_WRITE32(SYSTEM_CTRL_BASE,REG_OSC32K_REG_CTRL0, 0);
|
||||
|
||||
//offset 4 = 0x0100
|
||||
Rtemp = 0x840100;
|
||||
HAL_WRITE32(SYSTEM_CTRL_BASE,REG_OSC32K_REG_CTRL0, Rtemp);
|
||||
HalDelayUs(40);
|
||||
HAL_WRITE32(SYSTEM_CTRL_BASE,REG_OSC32K_REG_CTRL0, 0);
|
||||
|
||||
//offset 0 = 0xf980
|
||||
Rtemp = 0x80f980;
|
||||
HAL_WRITE32(SYSTEM_CTRL_BASE,REG_OSC32K_REG_CTRL0, Rtemp);
|
||||
HalDelayUs(40);
|
||||
HAL_WRITE32(SYSTEM_CTRL_BASE,REG_OSC32K_REG_CTRL0, 0);
|
||||
|
||||
while(1) {
|
||||
//Polling LOCK
|
||||
Rtemp = 0x110000;
|
||||
HAL_WRITE32(SYSTEM_CTRL_BASE,REG_OSC32K_REG_CTRL0, Rtemp);
|
||||
//DiagPrintf("Polling lock\n");
|
||||
HalDelayUs(40);
|
||||
|
||||
Rtemp = HAL_READ32(SYSTEM_CTRL_BASE,REG_OSC32K_REG_CTRL1);
|
||||
if ((Rtemp & 0x3000) != 0x0){
|
||||
#if CONFIG_DEBUG_LOG > 5
|
||||
DiagPrintf("32.768 Calibration Success\n", Ttemp);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
else {
|
||||
Ttemp++;
|
||||
HalDelayUs(30);
|
||||
#if CONFIG_DEBUG_LOG > 5
|
||||
DiagPrintf("Check lock: %d\n", Ttemp);
|
||||
DiagPrintf("0x278: %x\n", Rtemp);
|
||||
#endif
|
||||
if (Ttemp > 100000) { /*Delay 100ms*/
|
||||
DiagPrintf("32K Calibration Fail!\n", Ttemp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if CONFIG_WDG
|
||||
WDG_ADAPTER WDGAdapter;
|
||||
extern HAL_TIMER_OP HalTimerOp;
|
||||
|
||||
#ifdef CONFIG_WDG_NORMAL
|
||||
/*
|
||||
* pvvx: if WDT RESET_MODE:
|
||||
* HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN, HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) & 0x1FFFFF);
|
||||
*/
|
||||
void
|
||||
WDGInitial(
|
||||
IN uint32_t Period
|
||||
)
|
||||
{
|
||||
uint8_t CountId;
|
||||
uint16_t DivFactor;
|
||||
uint32_t CountTemp;
|
||||
uint32_t CountProcess = 0;
|
||||
uint32_t DivFacProcess = 0;
|
||||
uint32_t PeriodProcess = 100*Period;
|
||||
uint32_t MinPeriodTemp = 0xFFFFFFFF;
|
||||
uint32_t PeriodTemp = 0;
|
||||
uint32_t *Reg = (uint32_t*)&(WDGAdapter.Ctrl);
|
||||
|
||||
#if CONFIG_DEBUG_LOG > 1
|
||||
DBG_8195A("WdgPeriod = %d ms\n", Period);
|
||||
#endif
|
||||
for (CountId = 0; CountId < 12; CountId++) {
|
||||
CountTemp = ((0x00000001 << (CountId+1))-1);
|
||||
DivFactor = (uint16_t)((PeriodProcess)/(CountTemp*3));
|
||||
|
||||
if (DivFactor > 0) {
|
||||
PeriodTemp = 3*(DivFactor+1)*CountTemp;
|
||||
if (PeriodProcess < PeriodTemp) {
|
||||
if (MinPeriodTemp > PeriodTemp) {
|
||||
MinPeriodTemp = PeriodTemp;
|
||||
CountProcess = CountId;
|
||||
DivFacProcess = DivFactor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if CONFIG_DEBUG_LOG > 4
|
||||
DBG_8195A("WdgScalar = %p\n", DivFacProcess);
|
||||
DBG_8195A("WdgCunLimit = %p\n", CountProcess);
|
||||
#endif
|
||||
WDGAdapter.Ctrl.WdgScalar = DivFacProcess;
|
||||
WDGAdapter.Ctrl.WdgEnByte = 0;
|
||||
WDGAdapter.Ctrl.WdgClear = 1;
|
||||
WDGAdapter.Ctrl.WdgCunLimit = CountProcess;
|
||||
WDGAdapter.Ctrl.WdgMode = RESET_MODE;
|
||||
WDGAdapter.Ctrl.WdgToISR = 0;
|
||||
#if CONFIG_DEBUG_LOG > 4
|
||||
DBG_8195A("WdgCtrl = %p\n", (uint32_t)(*Reg));
|
||||
#endif
|
||||
HAL_WRITE32(VENDOR_REG_BASE, 0, (*Reg));
|
||||
}
|
||||
|
||||
void
|
||||
WDGIrqHandle
|
||||
(
|
||||
IN void *Data
|
||||
)
|
||||
{
|
||||
uint32_t temp;
|
||||
WDG_REG *CtrlReg;
|
||||
|
||||
if (NULL != WDGAdapter.UserCallback) {
|
||||
WDGAdapter.UserCallback(WDGAdapter.callback_id);
|
||||
}
|
||||
|
||||
// Clear ISR
|
||||
temp = HAL_READ32(VENDOR_REG_BASE, 0);
|
||||
CtrlReg = (WDG_REG*)&temp;
|
||||
CtrlReg->WdgToISR = 1; // write 1 clear
|
||||
HAL_WRITE32(VENDOR_REG_BASE, 0, (temp));
|
||||
}
|
||||
|
||||
void
|
||||
WDGIrqInitial(
|
||||
void
|
||||
)
|
||||
{
|
||||
uint32_t *Temp = (uint32_t*)&(WDGAdapter.Ctrl);
|
||||
|
||||
WDGAdapter.IrqHandle.Data = (uint32_t)&WDGAdapter;
|
||||
WDGAdapter.IrqHandle.IrqFun = (IRQ_FUN)WDGIrqHandle;
|
||||
WDGAdapter.IrqHandle.IrqNum = WDG_IRQ;
|
||||
WDGAdapter.IrqHandle.Priority = 0;
|
||||
|
||||
InterruptRegister(&(WDGAdapter.IrqHandle));
|
||||
InterruptEn(&(WDGAdapter.IrqHandle));
|
||||
|
||||
|
||||
WDGAdapter.Ctrl.WdgToISR = 1; // clear ISR first
|
||||
WDGAdapter.Ctrl.WdgMode = INT_MODE;
|
||||
HAL_WRITE32(VENDOR_REG_BASE, 0, ((*Temp)));
|
||||
WDGAdapter.Ctrl.WdgToISR = 0;
|
||||
}
|
||||
|
||||
void
|
||||
WDGStart(
|
||||
void
|
||||
)
|
||||
{
|
||||
uint32_t *Temp = (uint32_t*)&(WDGAdapter.Ctrl);
|
||||
WDGAdapter.Ctrl.WdgEnByte = 0xA5;
|
||||
HAL_WRITE32(VENDOR_REG_BASE, 0, ((*Temp)));
|
||||
}
|
||||
|
||||
void
|
||||
WDGStop(
|
||||
void
|
||||
)
|
||||
{
|
||||
uint32_t *Temp = (uint32_t*)&(WDGAdapter.Ctrl);
|
||||
WDGAdapter.Ctrl.WdgEnByte = 0;
|
||||
HAL_WRITE32(VENDOR_REG_BASE, 0, ((*Temp)));
|
||||
}
|
||||
|
||||
void
|
||||
WDGRefresh(
|
||||
void
|
||||
)
|
||||
{
|
||||
uint32_t *Temp = (uint32_t*)&(WDGAdapter.Ctrl);
|
||||
WDGAdapter.Ctrl.WdgClear = 1;
|
||||
HAL_WRITE32(VENDOR_REG_BASE, 0, ((*Temp)));
|
||||
}
|
||||
|
||||
void
|
||||
WDGIrqCallBackReg(
|
||||
IN void *CallBack,
|
||||
IN uint32_t Id
|
||||
)
|
||||
{
|
||||
WDGAdapter.UserCallback = (void (*)(uint32_t))CallBack;
|
||||
WDGAdapter.callback_id = Id;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_WDG_TEST
|
||||
void
|
||||
WDGIrqHandle
|
||||
(
|
||||
IN void *Data
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WDGGtimerHandle
|
||||
(
|
||||
IN void *Data
|
||||
)
|
||||
{
|
||||
uint32_t *Temp = (uint32_t*)&(WDGAdapter.Ctrl);
|
||||
WDGAdapter.Ctrl.WdgClear = 1;
|
||||
DBG_8195A("reset WDG\n");
|
||||
if (HAL_READ32(SYSTEM_CTRL_BASE,REG_SYS_DSTBY_INFO2) == 0) {
|
||||
HAL_WRITE32(VENDOR_REG_BASE, 0, ((*Temp)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InitWDGIRQ(void)
|
||||
{
|
||||
uint32_t *Temp = (uint32_t*)&(WDGAdapter.Ctrl);
|
||||
|
||||
WDGAdapter.Ctrl.WdgScalar = 0x96;
|
||||
WDGAdapter.Ctrl.WdgEnByte = 0xA5;
|
||||
WDGAdapter.Ctrl.WdgClear = 1;
|
||||
WDGAdapter.Ctrl.WdgCunLimit = CNTFFFH;
|
||||
WDGAdapter.Ctrl.WdgMode = RESET_MODE;
|
||||
WDGAdapter.Ctrl.WdgToISR = 0;
|
||||
|
||||
if (WDGAdapter.Ctrl.WdgMode == INT_MODE) {
|
||||
|
||||
WDGAdapter.IrqHandle.Data = NULL;
|
||||
WDGAdapter.IrqHandle.IrqFun = (IRQ_FUN)WDGIrqHandle;
|
||||
WDGAdapter.IrqHandle.IrqNum = WDG_IRQ;
|
||||
WDGAdapter.IrqHandle.Priority = 5;
|
||||
|
||||
InterruptRegister(&(WDGAdapter.IrqHandle));
|
||||
InterruptEn(&(WDGAdapter.IrqHandle));
|
||||
}
|
||||
else {
|
||||
|
||||
WDGAdapter.WdgGTimer.TimerIrqPriority = 0;
|
||||
WDGAdapter.WdgGTimer.TimerMode = USER_DEFINED;
|
||||
WDGAdapter.WdgGTimer.IrqDis = OFF;
|
||||
WDGAdapter.WdgGTimer.TimerId = 2;//
|
||||
WDGAdapter.WdgGTimer.IrqHandle.IrqFun = (IRQ_FUN)WDGGtimerHandle;
|
||||
WDGAdapter.WdgGTimer.IrqHandle.IrqNum = TIMER2_7_IRQ;
|
||||
WDGAdapter.WdgGTimer.IrqHandle.Priority = 5;
|
||||
WDGAdapter.WdgGTimer.IrqHandle.Data = NULL;
|
||||
|
||||
if ((WDGAdapter.Ctrl.WdgCunLimit == CNTFFFH)&&(WDGAdapter.Ctrl.WdgScalar >= 0x8429)){
|
||||
WDGAdapter.WdgGTimer.TimerLoadValueUs = 0xFFFFFFFF - WDGTIMERELY;
|
||||
}
|
||||
else {
|
||||
WDGAdapter.WdgGTimer.TimerLoadValueUs = (BIT0 << (WDGAdapter.Ctrl.WdgCunLimit+1))
|
||||
*WDGAdapter.Ctrl.WdgScalar*TIMER_TICK_US - WDGTIMERELY;
|
||||
}
|
||||
|
||||
HalTimerOp.HalTimerInit((void*) &(WDGAdapter.WdgGTimer));
|
||||
}
|
||||
//fill reg
|
||||
HAL_WRITE32(VENDOR_REG_BASE, 0, ((*Temp)));
|
||||
}
|
||||
|
||||
|
||||
//WDG
|
||||
void HalWdgInit(
|
||||
void
|
||||
)
|
||||
{
|
||||
|
||||
}
|
||||
#endif //CONFIG_WDG_TEST
|
||||
#endif //CONFIG_WDG
|
||||
#endif //#ifdef CONFIG_TIMER_MODULE
|
||||
1839
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_adc.c
Normal file
1839
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_adc.c
Normal file
File diff suppressed because it is too large
Load diff
318
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_adc.h
Normal file
318
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_adc.h
Normal file
|
|
@ -0,0 +1,318 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _HAL_ADC_H_
|
||||
#define _HAL_ADC_H_
|
||||
|
||||
#include "rtl8195a.h"
|
||||
#include "rtl8195a_adc.h"
|
||||
#include "hal_gdma.h"
|
||||
|
||||
//================ ADC Configuration =========================
|
||||
#define ADC_INTR_OP_TYPE 1
|
||||
#define ADC_DMA_OP_TYPE 1
|
||||
|
||||
// ADC SAL management macros
|
||||
#define SAL_ADC_USER_CB_NUM (sizeof(SAL_ADC_USER_CB) / sizeof(PSAL_ADC_USERCB_ADPT))
|
||||
|
||||
// ADC used module.
|
||||
// Please set the ADC module flag to 1 to enable the related
|
||||
#define ADC0_USED 1
|
||||
#define ADC1_USED 1
|
||||
#define ADC2_USED 1
|
||||
#define ADC3_USED 1
|
||||
|
||||
|
||||
//================ Debug MSG Definition =======================
|
||||
#define ADC_PREFIX "RTL8195A[adc]: "
|
||||
#define ADC_PREFIX_LVL " [ADC_DBG]: "
|
||||
|
||||
typedef enum _ADC_DBG_LVL_ {
|
||||
HAL_ADC_LVL = 0x01,
|
||||
SAL_ADC_LVL = 0x02,
|
||||
VERI_ADC_LVL = 0x04,
|
||||
}ADC_DBG_LVL,*PADC_DBG_LVL;
|
||||
|
||||
#ifdef CONFIG_DEBUG_LOG_ADC_HAL
|
||||
|
||||
#define DBG_8195A_ADC(...) do{ \
|
||||
_DbgDump(ADC_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
|
||||
#define ADCDBGLVL 0xFF
|
||||
#define DBG_8195A_ADC_LVL(LVL,...) do{\
|
||||
if (LVL&ADCDBGLVL){\
|
||||
_DbgDump(ADC_PREFIX_LVL __VA_ARGS__);\
|
||||
}\
|
||||
}while(0)
|
||||
#else
|
||||
#define DBG_ADC_LOG_PERD 100
|
||||
#define DBG_8195A_ADC(...)
|
||||
#define DBG_8195A_ADC_LVL(...)
|
||||
#endif
|
||||
|
||||
|
||||
//================ ADC HAL Related Enumeration ==================
|
||||
// ADC Module Selection
|
||||
typedef enum _ADC_MODULE_SEL_ {
|
||||
ADC0_SEL = 0x0,
|
||||
ADC1_SEL = 0x1,
|
||||
ADC2_SEL = 0x2,
|
||||
ADC3_SEL = 0x3,
|
||||
}ADC_MODULE_SEL,*PADC_MODULE_SEL;
|
||||
|
||||
// ADC module status
|
||||
typedef enum _ADC_MODULE_STATUS_ {
|
||||
ADC_DISABLE = 0x0,
|
||||
ADC_ENABLE = 0x1,
|
||||
}ADC_MODULE_STATUS, *PADC_MODULE_STATUS;
|
||||
|
||||
// ADC Data Endian
|
||||
typedef enum _ADC_DATA_ENDIAN_ {
|
||||
ADC_DATA_ENDIAN_LITTLE = 0x0,
|
||||
ADC_DATA_ENDIAN_BIG = 0x1,
|
||||
}ADC_DATA_ENDIAN,*PADC_DATA_ENDIAN;
|
||||
|
||||
// ADC Debug Select
|
||||
typedef enum _ADC_DEBUG_SEL_ {
|
||||
ADC_DBG_SEL_DISABLE = 0x0,
|
||||
ADC_DBG_SEL_ENABLE = 0x1,
|
||||
}ADC_DEBUG_SEL,*PADC_DEBUG_SEL;
|
||||
|
||||
typedef enum _ADC_COMPARE_SET_ {
|
||||
ADC_COMP_SMALLER_THAN = 0x0,
|
||||
ADC_COMP_GREATER_THAN = 0x1,
|
||||
}ADC_COMPARE_SET, *PADC_COMPARE_SET;
|
||||
|
||||
// ADC feature status
|
||||
typedef enum _ADC_FEATURE_STATUS_{
|
||||
ADC_FEATURE_DISABLED = 0,
|
||||
ADC_FEATURE_ENABLED = 1,
|
||||
}ADC_FEATURE_STATUS,*PADC_FEATURE_STATUS;
|
||||
|
||||
// ADC operation type
|
||||
typedef enum _ADC_OP_TYPE_ {
|
||||
ADC_RDREG_TYPE = 0x0,
|
||||
ADC_DMA_TYPE = 0x1,
|
||||
ADC_INTR_TYPE = 0x2,
|
||||
}ADC_OP_TYPE, *PADC_OP_TYPE;
|
||||
|
||||
// ADC device status
|
||||
typedef enum _ADC_DEVICE_STATUS_ {
|
||||
ADC_STS_UNINITIAL = 0x00,
|
||||
ADC_STS_INITIALIZED = 0x01,
|
||||
ADC_STS_IDLE = 0x02,
|
||||
|
||||
ADC_STS_TX_READY = 0x03,
|
||||
ADC_STS_TX_ING = 0x04,
|
||||
|
||||
ADC_STS_RX_READY = 0x05,
|
||||
ADC_STS_RX_ING = 0x06,
|
||||
|
||||
ADC_STS_ERROR = 0x07,
|
||||
ADC_STS_FULL = 0x08,
|
||||
}ADC_DEVICE_STATUS, *PADC_DEVICE_STATUS;
|
||||
|
||||
// ADC error type
|
||||
typedef enum _ADC_ERR_TYPE_ {
|
||||
ADC_ERR_FIFO_RD_ERROR = 0x40, //ADC FIFO read error
|
||||
}ADC_ERR_TYPE, *PADC_ERR_TYPE;
|
||||
|
||||
// ADC initial status
|
||||
typedef enum _ADC_INITAIL_STATUS_ {
|
||||
ADC0_INITED = 0x1,
|
||||
ADC1_INITED = 0x2,
|
||||
ADC2_INITED = 0x4,
|
||||
ADC3_INITED = 0x8,
|
||||
}ADC_INITAIL_STATUS, *PADC_INITAIL_STATUS;
|
||||
|
||||
|
||||
//================ ADC HAL Data Structure ======================
|
||||
// ADC HAL initial data structure
|
||||
typedef struct _HAL_ADC_INIT_DAT_ {
|
||||
uint8_t ADCIdx; //ADC index used
|
||||
uint8_t ADCEn; //ADC module enable
|
||||
uint8_t ADCEndian; //ADC endian selection,
|
||||
//but actually it's for 32-bit ADC data swap control
|
||||
//1'b0: no swap,
|
||||
//1'b1: swap the upper 16-bit and the lower 16-bit
|
||||
uint8_t ADCBurstSz; //ADC DMA operation threshold
|
||||
|
||||
uint8_t ADCCompOnly; //ADC compare mode only enable (without FIFO enable)
|
||||
uint8_t ADCOneShotEn; //ADC one-shot mode enable
|
||||
uint8_t ADCOverWREn; //ADC overwrite mode enable
|
||||
uint8_t ADCOneShotTD; //ADC one shot mode threshold
|
||||
|
||||
uint16_t ADCCompCtrl; //ADC compare mode control,
|
||||
//1'b0:less than the compare threshold
|
||||
//1'b1:greater than the compare threshod
|
||||
uint16_t ADCCompTD; //ADC compare mode threshold
|
||||
|
||||
uint8_t ADCDataRate; //ADC down sample data rate,
|
||||
uint8_t ADCAudioEn; //ADC audio mode enable
|
||||
uint8_t ADCEnManul; //ADC enable manually
|
||||
uint8_t ADCDbgSel;
|
||||
|
||||
uint32_t RSVD0;
|
||||
|
||||
uint32_t *ADCData; //ADC data pointer
|
||||
uint32_t ADCPWCtrl; //ADC0 power control
|
||||
uint32_t ADCIntrMSK; //ADC Interrupt Mask
|
||||
uint32_t ADCAnaParAd3; //ADC analog parameter 3
|
||||
uint32_t ADCInInput; //ADC Input is internal?
|
||||
}HAL_ADC_INIT_DAT,*PHAL_ADC_INIT_DAT;
|
||||
|
||||
// ADC HAL Operations
|
||||
typedef struct _HAL_ADC_OP_ {
|
||||
RTK_STATUS (*HalADCInit) (void *Data); //HAL ADC initialization
|
||||
RTK_STATUS (*HalADCDeInit) (void *Data); //HAL ADC de-initialization
|
||||
RTK_STATUS (*HalADCEnable) (void *Data); //HAL ADC de-initialization
|
||||
uint32_t (*HalADCReceive) (void *Data); //HAL ADC receive
|
||||
RTK_STATUS (*HalADCIntrCtrl) (void *Data); //HAL ADC interrupt control
|
||||
uint32_t (*HalADCReadReg) (void *Data, uint8_t ADCReg);//HAL ADC read register
|
||||
}HAL_ADC_OP, *PHAL_ADC_OP;
|
||||
|
||||
// ADC user callback adapter
|
||||
typedef struct _SAL_ADC_USERCB_ADPT_ {
|
||||
void (*USERCB) (void *Data);
|
||||
uint32_t USERData;
|
||||
}SAL_ADC_USERCB_ADPT, *PSAL_ADC_USERCB_ADPT;
|
||||
|
||||
// ADC user callback structure
|
||||
typedef struct _SAL_ADC_USER_CB_ {
|
||||
PSAL_ADC_USERCB_ADPT pTXCB; //ADC Transmit Callback
|
||||
PSAL_ADC_USERCB_ADPT pTXCCB; //ADC Transmit Complete Callback
|
||||
PSAL_ADC_USERCB_ADPT pRXCB; //ADC Receive Callback
|
||||
PSAL_ADC_USERCB_ADPT pRXCCB; //ADC Receive Complete Callback
|
||||
PSAL_ADC_USERCB_ADPT pRDREQCB; //ADC Read Request Callback
|
||||
PSAL_ADC_USERCB_ADPT pERRCB; //ADC Error Callback
|
||||
PSAL_ADC_USERCB_ADPT pDMATXCB; //ADC DMA Transmit Callback
|
||||
PSAL_ADC_USERCB_ADPT pDMATXCCB; //ADC DMA Transmit Complete Callback
|
||||
PSAL_ADC_USERCB_ADPT pDMARXCB; //ADC DMA Receive Callback
|
||||
PSAL_ADC_USERCB_ADPT pDMARXCCB; //ADC DMA Receive Complete Callback
|
||||
}SAL_ADC_USER_CB, *PSAL_ADC_USER_CB;
|
||||
|
||||
// ADC Transmit Buffer
|
||||
typedef struct _SAL_ADC_TRANSFER_BUF_ {
|
||||
uint32_t DataLen; //ADC Transmfer Length
|
||||
uint32_t *pDataBuf; //ADC Transfer Buffer Pointer
|
||||
uint32_t RSVD; //
|
||||
}SAL_ADC_TRANSFER_BUF,*PSAL_ADC_TRANSFER_BUF;
|
||||
|
||||
typedef struct _SAL_ADC_DMA_USER_DEF_ {
|
||||
|
||||
uint8_t TxDatSrcWdth;
|
||||
uint8_t TxDatDstWdth;
|
||||
uint8_t TxDatSrcBstSz;
|
||||
uint8_t TxDatDstBstSz;
|
||||
|
||||
uint8_t TxChNo;
|
||||
uint8_t LlpCtrl;
|
||||
uint16_t RSVD0;
|
||||
|
||||
uint32_t MaxMultiBlk;
|
||||
uint32_t pLlix;
|
||||
uint32_t pBlockSizeList;
|
||||
}SAL_ADC_DMA_USER_DEF, *PSAL_ADC_DMA_USER_DEF;
|
||||
|
||||
// Software API Level ADC Handler
|
||||
typedef struct _SAL_ADC_HND_ {
|
||||
uint8_t DevNum; //ADC device number
|
||||
uint8_t PinMux; //ADC pin mux seletion
|
||||
uint8_t OpType; //ADC operation type selection
|
||||
volatile uint8_t DevSts; //ADC device status
|
||||
|
||||
uint32_t ADCExd; //ADC extended options:
|
||||
//bit 0: example
|
||||
//bit 31~bit 1: Reserved
|
||||
uint32_t ErrType; //
|
||||
uint32_t TimeOut; //ADC IO Timeout count
|
||||
|
||||
PHAL_ADC_INIT_DAT pInitDat; //Pointer to ADC initial data struct
|
||||
PSAL_ADC_TRANSFER_BUF pRXBuf; //Pointer to ADC TX buffer
|
||||
PSAL_ADC_USER_CB pUserCB; //Pointer to ADC User Callback
|
||||
}SAL_ADC_HND, *PSAL_ADC_HND;
|
||||
|
||||
// ADC SAL handle private
|
||||
typedef struct _SAL_ADC_HND_PRIV_ {
|
||||
void **ppSalADCHnd; //Pointer to SAL_ADC_HND pointer
|
||||
SAL_ADC_HND SalADCHndPriv; //Private SAL_ADC_HND
|
||||
}SAL_ADC_HND_PRIV, *PSAL_ADC_HND_PRIV;
|
||||
|
||||
//ADC SAL management adapter
|
||||
typedef struct _SAL_ADC_MNGT_ADPT_ {
|
||||
PSAL_ADC_HND_PRIV pSalHndPriv; //Pointer to SAL_ADC_HND
|
||||
PHAL_ADC_INIT_DAT pHalInitDat; //Pointer to HAL ADC initial data( HAL_ADC_INIT_DAT )
|
||||
PHAL_ADC_OP pHalOp; //Pointer to HAL ADC operation( HAL_ADC_OP )
|
||||
void (*pHalOpInit)(void*);//Pointer to HAL ADC initialize function
|
||||
|
||||
PIRQ_HANDLE pIrqHnd; //Pointer to IRQ handler in SAL layer( IRQ_HANDLE )
|
||||
void (*pSalIrqFunc)(void*); //Used for SAL ADC interrupt function
|
||||
|
||||
PSAL_ADC_DMA_USER_DEF pDMAConf; //Pointer to DAC User Define DMA config
|
||||
PHAL_GDMA_ADAPTER pHalGdmaAdp;
|
||||
PHAL_GDMA_OP pHalGdmaOp;
|
||||
PIRQ_HANDLE pIrqGdmaHnd;
|
||||
void (*pHalGdmaOpInit)(void*); //Pointer to HAL DAC initialize function
|
||||
PSAL_ADC_USER_CB pUserCB; //Pointer to SAL user callbacks (SAL_ADC_USER_CB )
|
||||
void (*pSalDMAIrqFunc)(void*); //Used for SAL DAC interrupt function
|
||||
}SAL_ADC_MNGT_ADPT, *PSAL_ADC_MNGT_ADPT;
|
||||
|
||||
|
||||
//================ ADC HAL Function Prototype ===================
|
||||
// ADC HAL inline function
|
||||
// For checking I2C input index valid or not
|
||||
static inline RTK_STATUS
|
||||
RtkADCIdxChk(
|
||||
IN uint8_t ADCIdx
|
||||
)
|
||||
{
|
||||
#if !ADC0_USED
|
||||
if (ADCIdx == ADC0_SEL)
|
||||
return _EXIT_FAILURE;
|
||||
#endif
|
||||
|
||||
#if !ADC1_USED
|
||||
if (ADCIdx == ADC1_SEL)
|
||||
return _EXIT_FAILURE;
|
||||
#endif
|
||||
|
||||
#if !ADC2_USED
|
||||
if (ADCIdx == ADC2_SEL)
|
||||
return _EXIT_FAILURE;
|
||||
#endif
|
||||
|
||||
#if !ADC3_USED
|
||||
if (ADCIdx == ADC3_SEL)
|
||||
return _EXIT_FAILURE;
|
||||
#endif
|
||||
ADCIdx++; //for compile warning.
|
||||
return _EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
void HalADCOpInit(IN void *Data);
|
||||
PSAL_ADC_HND RtkADCGetSalHnd(IN uint8_t DACIdx);
|
||||
RTK_STATUS RtkADCFreeSalHnd(IN PSAL_ADC_HND pSalADCHND);
|
||||
RTK_STATUS RtkADCLoadDefault(IN void *Data);
|
||||
RTK_STATUS RtkADCInit(IN void *Data);
|
||||
RTK_STATUS RtkADCDeInit(IN void *Data);
|
||||
//RTK_STATUS RtkADCReceive(IN void *Data);
|
||||
uint32_t RtkADCReceive(IN void *Data);
|
||||
uint32_t RtkADCReceiveBuf(IN void *Data,IN uint32_t *pBuf);
|
||||
uint32_t RtkADCRxManualRotate(IN void *Data,IN uint32_t *pBuf);
|
||||
|
||||
PSAL_ADC_MNGT_ADPT RtkADCGetMngtAdpt(IN uint8_t ADCIdx);
|
||||
RTK_STATUS RtkADCFreeMngtAdpt(IN PSAL_ADC_MNGT_ADPT pSalADCMngtAdpt);
|
||||
void ADCISRHandle(IN void *Data);
|
||||
void ADCGDMAISRHandle(IN void *Data);
|
||||
HAL_Status RtkADCDisablePS(IN void *Data);
|
||||
HAL_Status RtkADCEnablePS(IN void *Data);
|
||||
|
||||
#endif
|
||||
126
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_api.h
Normal file
126
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_api.h
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
#ifndef _HAL_API_H_
|
||||
#define _HAL_API_H_
|
||||
|
||||
#include "basic_types.h"
|
||||
#include "hal_irqn.h"
|
||||
|
||||
#define HAL_READ32(base, addr) \
|
||||
rtk_le32_to_cpu(*((volatile uint32_t*)(base + addr)))
|
||||
|
||||
#define HAL_WRITE32(base, addr, value32) \
|
||||
((*((volatile uint32_t*)(base + addr))) = rtk_cpu_to_le32(value32))
|
||||
|
||||
|
||||
#define HAL_READ16(base, addr) \
|
||||
rtk_le16_to_cpu(*((volatile uint16_t*)(base + addr)))
|
||||
|
||||
#define HAL_WRITE16(base, addr, value) \
|
||||
((*((volatile uint16_t*)(base + addr))) = rtk_cpu_to_le16(value))
|
||||
|
||||
|
||||
#define HAL_READ8(base, addr) \
|
||||
(*((volatile uint8_t*)(base + addr)))
|
||||
|
||||
#define HAL_WRITE8(base, addr, value) \
|
||||
((*((volatile uint8_t*)(base + addr))) = value)
|
||||
|
||||
#if 0
|
||||
// These "extern _LONG_CALL_" function declaration are for RAM code building only
|
||||
// For ROM code building, thses code should be marked off
|
||||
extern _LONG_CALL_ uint8_t
|
||||
HalPinCtrlRtl8195A(
|
||||
IN uint32_t Function,
|
||||
IN uint32_t PinLocation,
|
||||
IN BOOL Operation
|
||||
);
|
||||
|
||||
extern _LONG_CALL_ void
|
||||
HalSerialPutcRtl8195a(
|
||||
IN uint8_t c
|
||||
);
|
||||
|
||||
extern _LONG_CALL_ uint8_t
|
||||
HalSerialGetcRtl8195a(
|
||||
IN BOOL PullMode
|
||||
);
|
||||
|
||||
extern _LONG_CALL_ uint32_t
|
||||
HalSerialGetIsrEnRegRtl8195a(void);
|
||||
|
||||
extern _LONG_CALL_ void
|
||||
HalSerialSetIrqEnRegRtl8195a (
|
||||
IN uint32_t SetValue
|
||||
);
|
||||
|
||||
extern _LONG_CALL_ void
|
||||
VectorTableInitForOSRtl8195A(
|
||||
IN void *PortSVC,
|
||||
IN void *PortPendSVH,
|
||||
IN void *PortSysTick
|
||||
);
|
||||
|
||||
extern _LONG_CALL_ BOOL
|
||||
VectorIrqRegisterRtl8195A(
|
||||
IN PIRQ_HANDLE pIrqHandle
|
||||
);
|
||||
|
||||
extern _LONG_CALL_ BOOL
|
||||
VectorIrqUnRegisterRtl8195A(
|
||||
IN PIRQ_HANDLE pIrqHandle
|
||||
);
|
||||
|
||||
extern _LONG_CALL_ void
|
||||
VectorIrqEnRtl8195A(
|
||||
IN PIRQ_HANDLE pIrqHandle
|
||||
);
|
||||
|
||||
extern _LONG_CALL_ void
|
||||
VectorIrqDisRtl8195A(
|
||||
IN PIRQ_HANDLE pIrqHandle
|
||||
);
|
||||
#endif
|
||||
|
||||
extern BOOLEAN SpicFlashInitRtl8195A(uint8_t SpicBitMode);
|
||||
extern void InitWDGIRQ(void);
|
||||
|
||||
#define PinCtrl HalPinCtrlRtl8195A
|
||||
|
||||
#define DiagPutChar HalSerialPutcRtl8195a
|
||||
#define DiagGetChar HalSerialGetcRtl8195a
|
||||
#define DiagGetIsrEnReg HalSerialGetIsrEnRegRtl8195a
|
||||
#define DiagSetIsrEnReg HalSerialSetIrqEnRegRtl8195a
|
||||
|
||||
#define InterruptForOSInit VectorTableInitForOSRtl8195A
|
||||
#define InterruptRegister VectorIrqRegisterRtl8195A
|
||||
#define InterruptUnRegister VectorIrqUnRegisterRtl8195A
|
||||
|
||||
#define InterruptEn VectorIrqEnRtl8195A
|
||||
#define InterruptDis VectorIrqDisRtl8195A
|
||||
|
||||
#define SpicFlashInit SpicFlashInitRtl8195A
|
||||
#define Calibration32k En32KCalibration
|
||||
#define WDGInit InitWDGIRQ
|
||||
|
||||
typedef enum _HAL_Status
|
||||
{
|
||||
HAL_OK = 0x00,
|
||||
HAL_BUSY = 0x01,
|
||||
HAL_TIMEOUT = 0x02,
|
||||
HAL_ERR_PARA = 0x03, // error with invaild parameters
|
||||
HAL_ERR_MEM = 0x04, // error with memory allocation failed
|
||||
HAL_ERR_HW = 0x05, // error with hardware error
|
||||
|
||||
HAL_ERR_UNKNOWN = 0xee // unknown error
|
||||
|
||||
} HAL_Status;
|
||||
|
||||
|
||||
#endif //_HAL_API_H_
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#include "rtl8195a.h"
|
||||
#include "hal_common.h"
|
||||
|
||||
extern HAL_TIMER_OP HalTimerOp;
|
||||
|
||||
HAL_Status
|
||||
HalCommonInit(void){
|
||||
|
||||
#ifdef CONFIG_TIMER_MODULE
|
||||
HalTimerOpInit_Patch((void*)(&HalTimerOp));
|
||||
#endif
|
||||
|
||||
return HAL_OK;
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _HAL_COMMON_H_
|
||||
#define _HAL_COMMON_H_
|
||||
|
||||
//================= Function Prototype START ===================
|
||||
HAL_Status HalCommonInit(void);
|
||||
//================= Function Prototype END ===================
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,214 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __HAL_CRYPTO_H__
|
||||
#define __HAL_CRYPTO_H__
|
||||
|
||||
|
||||
#include "hal_api.h"
|
||||
#include "basic_types.h"
|
||||
|
||||
|
||||
#define CRYPTO_MAX_MSG_LENGTH 16000
|
||||
#define CRYPTO_MD5_DIGEST_LENGTH 16
|
||||
#define CRYPTO_SHA1_DIGEST_LENGTH 20
|
||||
#define CRYPTO_SHA2_DIGEST_LENGTH 32
|
||||
|
||||
|
||||
typedef enum _SHA2_TYPE_ {
|
||||
SHA2_NONE = 0,
|
||||
SHA2_224 = 224/8,
|
||||
SHA2_256 = 256/8,
|
||||
SHA2_384 = 384/8,
|
||||
SHA2_512 = 512/8
|
||||
} SHA2_TYPE;
|
||||
|
||||
|
||||
#define _ERRNO_CRYPTO_DESC_NUM_SET_OutRange -2
|
||||
#define _ERRNO_CRYPTO_BURST_NUM_SET_OutRange -3
|
||||
#define _ERRNO_CRYPTO_NULL_POINTER -4
|
||||
#define _ERRNO_CRYPTO_ENGINE_NOT_INIT -5
|
||||
#define _ERRNO_CRYPTO_ADDR_NOT_4Byte_Aligned -6
|
||||
#define _ERRNO_CRYPTO_KEY_OutRange -7
|
||||
#define _ERRNO_CRYPTO_MSG_OutRange -8
|
||||
#define _ERRNO_CRYPTO_IV_OutRange -9
|
||||
#define _ERRNO_CRYPTO_AUTH_TYPE_NOT_MATCH -10
|
||||
#define _ERRNO_CRYPTO_CIPHER_TYPE_NOT_MATCH -11
|
||||
#define _ERRNO_CRYPTO_KEY_IV_LEN_DIFF -12
|
||||
#define _ERRNO_CRYPTO_AES_MSGLEN_NOT_16Byte_Aligned -13
|
||||
|
||||
|
||||
|
||||
//
|
||||
// External API Functions
|
||||
//
|
||||
|
||||
|
||||
// Crypto Engine
|
||||
extern int rtl_cryptoEngine_init(void);
|
||||
extern void rtl_cryptoEngine_info(void);
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Authentication
|
||||
//
|
||||
|
||||
// md5
|
||||
|
||||
extern int rtl_crypto_md5(IN const uint8_t* message, IN const uint32_t msglen, OUT uint8_t* pDigest);
|
||||
|
||||
extern int rtl_crypto_md5_init(void);
|
||||
extern int rtl_crypto_md5_process(IN const uint8_t* message, const IN uint32_t msglen, OUT uint8_t* pDigest);
|
||||
|
||||
|
||||
// sha1
|
||||
extern int rtl_crypto_sha1(IN const uint8_t* message, IN const uint32_t msglen, OUT uint8_t* pDigest);
|
||||
|
||||
extern int rtl_crypto_sha1_init(void);
|
||||
extern int rtl_crypto_sha1_process(IN const uint8_t* message, IN const uint32_t msglen, OUT uint8_t* pDigest);
|
||||
|
||||
// sha2
|
||||
|
||||
extern int rtl_crypto_sha2(IN const SHA2_TYPE sha2type,
|
||||
IN const uint8_t* message, IN const uint32_t msglen, OUT uint8_t* pDigest);
|
||||
|
||||
extern int rtl_crypto_sha2_init(IN const SHA2_TYPE sha2type);
|
||||
extern int rtl_crypto_sha2_process(IN const uint8_t* message, IN const uint32_t msglen, OUT uint8_t* pDigest);
|
||||
|
||||
|
||||
// HMAC-md5
|
||||
extern int rtl_crypto_hmac_md5(IN const uint8_t* message, IN const uint32_t msglen,
|
||||
IN const uint8_t* key, IN const uint32_t keylen, OUT uint8_t* pDigest);
|
||||
|
||||
extern int rtl_crypto_hmac_md5_init(IN const uint8_t* key, IN const uint32_t keylen);
|
||||
extern int rtl_crypto_hmac_md5_process(IN const uint8_t* message, IN const uint32_t msglen, OUT uint8_t* pDigest);
|
||||
|
||||
|
||||
// HMAC-sha1
|
||||
extern int rtl_crypto_hmac_sha1(IN const uint8_t* message, IN const uint32_t msglen,
|
||||
IN const uint8_t* key, IN const uint32_t keylen, OUT uint8_t* pDigest);
|
||||
|
||||
extern int rtl_crypto_hmac_sha1_init(IN const uint8_t* key, IN const uint32_t keylen);
|
||||
extern int rtl_crypto_hmac_sha1_process(IN const uint8_t* message, IN const uint32_t msglen, OUT uint8_t* pDigest);
|
||||
|
||||
|
||||
// HMAC-sha2
|
||||
extern int rtl_crypto_hmac_sha2(IN const SHA2_TYPE sha2type, IN const uint8_t* message, IN const uint32_t msglen,
|
||||
IN const uint8_t* key, IN const uint32_t keylen, OUT uint8_t* pDigest);
|
||||
|
||||
extern int rtl_crypto_hmac_sha2_init(IN const SHA2_TYPE sha2type, IN const uint8_t* key, IN const uint32_t keylen);
|
||||
extern int rtl_crypto_hmac_sha2_process(IN const uint8_t* message, IN const uint32_t msglen, OUT uint8_t* pDigest);
|
||||
|
||||
|
||||
//
|
||||
// Cipher Functions
|
||||
//
|
||||
|
||||
// AES - CBC
|
||||
|
||||
extern int rtl_crypto_aes_cbc_init(IN const uint8_t* key, IN const uint32_t keylen);
|
||||
|
||||
extern int rtl_crypto_aes_cbc_encrypt(
|
||||
IN const uint8_t* message, IN const uint32_t msglen,
|
||||
IN const uint8_t* iv, IN const uint32_t ivlen, OUT uint8_t* pResult);
|
||||
|
||||
extern int rtl_crypto_aes_cbc_decrypt(
|
||||
IN const uint8_t* message, IN const uint32_t msglen,
|
||||
IN const uint8_t* iv, IN const uint32_t ivlen, OUT uint8_t* pResult);
|
||||
|
||||
|
||||
// AES - ECB
|
||||
|
||||
extern int rtl_crypto_aes_ecb_init(IN const uint8_t* key, IN const uint32_t keylen);
|
||||
|
||||
extern int rtl_crypto_aes_ecb_encrypt(
|
||||
IN const uint8_t* message, IN const uint32_t msglen,
|
||||
IN const uint8_t* iv, IN const uint32_t ivlen, OUT uint8_t* pResult);
|
||||
|
||||
extern int rtl_crypto_aes_ecb_decrypt(
|
||||
IN const uint8_t* message, IN const uint32_t msglen,
|
||||
IN const uint8_t* iv, IN const uint32_t ivlen, OUT uint8_t* pResult);
|
||||
|
||||
|
||||
// AES - CTR
|
||||
|
||||
extern int rtl_crypto_aes_ctr_init(IN const uint8_t* key, IN const uint32_t keylen);
|
||||
|
||||
extern int rtl_crypto_aes_ctr_encrypt(
|
||||
IN const uint8_t* message, IN const uint32_t msglen,
|
||||
IN const uint8_t* iv, IN const uint32_t ivlen, OUT uint8_t* pResult);
|
||||
|
||||
extern int rtl_crypto_aes_ctr_decrypt(
|
||||
IN const uint8_t* message, IN const uint32_t msglen,
|
||||
IN const uint8_t* iv, IN const uint32_t ivlen, OUT uint8_t* pResult);
|
||||
|
||||
|
||||
// 3DES - CBC
|
||||
|
||||
extern int rtl_crypto_3des_cbc_init(IN const uint8_t* key, IN const uint32_t keylen);
|
||||
|
||||
extern int rtl_crypto_3des_cbc_encrypt(
|
||||
IN const uint8_t* message, IN const uint32_t msglen,
|
||||
IN const uint8_t* iv, IN const uint32_t ivlen, OUT uint8_t* pResult);
|
||||
|
||||
extern int rtl_crypto_3des_cbc_decrypt(
|
||||
IN const uint8_t* message, IN const uint32_t msglen,
|
||||
IN const uint8_t* iv, IN const uint32_t ivlen, OUT uint8_t* pResult);
|
||||
|
||||
|
||||
// 3DES - ECB
|
||||
|
||||
extern int rtl_crypto_3des_ecb_init(IN const uint8_t* key, IN const uint32_t keylen);
|
||||
|
||||
extern int rtl_crypto_3des_ecb_encrypt(
|
||||
IN const uint8_t* message, IN const uint32_t msglen,
|
||||
IN const uint8_t* iv, IN const uint32_t ivlen, OUT uint8_t* pResult);
|
||||
|
||||
extern int rtl_crypto_3des_ecb_decrypt(
|
||||
IN const uint8_t* message, IN const uint32_t msglen,
|
||||
IN const uint8_t* iv, IN const uint32_t ivlen, OUT uint8_t* pResult);
|
||||
|
||||
|
||||
// DES - CBC
|
||||
|
||||
extern int rtl_crypto_des_cbc_init(IN const uint8_t* key, IN const uint32_t keylen);
|
||||
|
||||
extern int rtl_crypto_des_cbc_encrypt(
|
||||
IN const uint8_t* message, IN const uint32_t msglen,
|
||||
IN const uint8_t* iv, IN const uint32_t ivlen, OUT uint8_t* pResult);
|
||||
|
||||
extern int rtl_crypto_des_cbc_decrypt(
|
||||
IN const uint8_t* message, IN const uint32_t msglen,
|
||||
IN const uint8_t* iv, IN const uint32_t ivlen, OUT uint8_t* pResult);
|
||||
|
||||
|
||||
// DES - ECB
|
||||
|
||||
extern int rtl_crypto_des_ecb_init(IN const uint8_t* key, IN const uint32_t keylen);
|
||||
|
||||
extern int rtl_crypto_des_ecb_encrypt(
|
||||
IN const uint8_t* message, IN const uint32_t msglen,
|
||||
IN const uint8_t* iv, IN const uint32_t ivlen, OUT uint8_t* pResult);
|
||||
|
||||
extern int rtl_crypto_des_ecb_decrypt(
|
||||
IN const uint8_t* message, IN const uint32_t msglen,
|
||||
IN const uint8_t* iv, IN const uint32_t ivlen, OUT uint8_t* pResult);
|
||||
|
||||
|
||||
//
|
||||
// C functions in ROM
|
||||
//
|
||||
|
||||
extern int rtl_memcmpb(const uint8_t *dst, const uint8_t *src, int bytes);
|
||||
extern int rtl_memcpyb(uint8_t *dst, const uint8_t *src, int bytes);
|
||||
|
||||
#endif /* __HAL_CRYPTO_H__ */
|
||||
|
||||
1561
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_dac.c
Normal file
1561
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_dac.c
Normal file
File diff suppressed because it is too large
Load diff
314
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_dac.h
Normal file
314
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_dac.h
Normal file
|
|
@ -0,0 +1,314 @@
|
|||
//======================================================
|
||||
// Routines to access hardware
|
||||
//
|
||||
// Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
//
|
||||
// This module is a confidential and proprietary property of RealTek and
|
||||
// possession or use of this module requires written permission of RealTek.
|
||||
//======================================================
|
||||
#ifndef _HAL_DAC_H_
|
||||
#define _HAL_DAC_H_
|
||||
|
||||
#include "rtl8195a.h"
|
||||
#include "rtl8195a_dac.h"
|
||||
#include "hal_api.h"
|
||||
#include "hal_gdma.h"
|
||||
|
||||
//================ DAC Configuration =========================
|
||||
#define DAC_INTR_OP_TYPE 1
|
||||
#define DAC_DMA_OP_TYPE 1
|
||||
|
||||
// DAC SAL management macros
|
||||
#define SAL_DAC_USER_CB_NUM (sizeof(SAL_DAC_USER_CB) / sizeof(PSAL_DAC_USERCB_ADPT))
|
||||
|
||||
// DAC SAL used module.
|
||||
// Please set the DAC module flag to 1 to enable the related DAC module functions.
|
||||
#define DAC0_USED 1
|
||||
#define DAC1_USED 1
|
||||
|
||||
|
||||
//================ Debug MSG Definition =======================
|
||||
#define DAC_PREFIX "RTL8195A[dac]: "
|
||||
#define DAC_PREFIX_LVL " [DAC_DBG]: "
|
||||
|
||||
typedef enum _DAC_DBG_LVL_ {
|
||||
HAL_DAC_LVL = 0x00,
|
||||
SAL_DAC_LVL = 0x02,
|
||||
VERI_DAC_LVL = 0x04,
|
||||
}DAC_DBG_LVL,*PDAC_DBG_LVL;
|
||||
|
||||
#if CONFIG_DEBUG_LOG > 0
|
||||
#ifdef CONFIG_DEBUG_LOG_DAC_HAL
|
||||
|
||||
#define DBG_8195A_DAC(...) do{ \
|
||||
_DbgDump(DAC_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
|
||||
#define DACDBGLVL 0xFF
|
||||
#define DBG_8195A_DAC_LVL(LVL,...) do{\
|
||||
if (LVL&DACDBGLVL){\
|
||||
_DbgDump(DAC_PREFIX_LVL __VA_ARGS__);\
|
||||
}\
|
||||
}while(0)
|
||||
#else
|
||||
#define DBG_DAC_LOG_PERD 100
|
||||
#define DBG_8195A_DAC(...)
|
||||
#define DBG_8195A_DAC_LVL(...)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
//================ DAC HAL Related Enumeration ==================
|
||||
// DAC Module Selection
|
||||
typedef enum _DAC_MODULE_SEL_ {
|
||||
DAC0_SEL = 0x0,
|
||||
DAC1_SEL = 0x1,
|
||||
}DAC_MODULE_SEL,*PDAC_MODULE_SEL;
|
||||
|
||||
// DAC module status
|
||||
typedef enum _DAC_MODULE_STATUS_ {
|
||||
DAC_DISABLE = 0x0,
|
||||
DAC_ENABLE = 0x1,
|
||||
}DAC_MODULE_STATUS, *PDAC_MODULE_STATUS;
|
||||
|
||||
// DAC Data Rate
|
||||
typedef enum _DAC_DATA_RATE_ {
|
||||
DAC_DATA_RATE_10K = 0x0,
|
||||
DAC_DATA_RATE_250K = 0x1,
|
||||
}DAC_DATA_RATE,*PDAC_DATA_RATE;
|
||||
|
||||
// DAC Data Endian
|
||||
typedef enum _DAC_DATA_ENDIAN_ {
|
||||
DAC_DATA_ENDIAN_LITTLE = 0x0,
|
||||
DAC_DATA_ENDIAN_BIG = 0x1,
|
||||
}DAC_DATA_ENDIAN,*PDAC_DATA_ENDIAN;
|
||||
|
||||
// DAC Debug Select
|
||||
typedef enum _DAC_DEBUG_SEL_ {
|
||||
DAC_DBG_SEL_DISABLE = 0x0,
|
||||
DAC_DBG_SEL_ENABLE = 0x1,
|
||||
}DAC_DEBUG_SEL,*PDAC_DEBUG_SEL;
|
||||
|
||||
// DAC Dsc Debug Select
|
||||
typedef enum _DAC_DSC_DEBUG_SEL_ {
|
||||
DAC_DSC_DBG_SEL_DISABLE = 0x0,
|
||||
DAC_DSC_DBG_SEL_ENABLE = 0x1,
|
||||
}DAC_DSC_DEBUG_SEL,*PDAC_DSC_DEBUG_SEL;
|
||||
|
||||
|
||||
// DAC Bypass Dsc Debug Select
|
||||
typedef enum _DAC_BYPASS_DSC_SEL_ {
|
||||
DAC_BYPASS_DSC_SEL_DISABLE = 0x0,
|
||||
DAC_BYPASS_DSC_SEL_ENABLE = 0x1,
|
||||
}DAC_BYPASS_DSC_SEL,*PDAC_BYPASS_DSC_SEL;
|
||||
|
||||
// DAC feature status
|
||||
typedef enum _DAC_FEATURE_STATUS_{
|
||||
DAC_FEATURE_DISABLED = 0,
|
||||
DAC_FEATURE_ENABLED = 1,
|
||||
}DAC_FEATURE_STATUS,*PDAC_FEATURE_STATUS;
|
||||
|
||||
// DAC operation type
|
||||
typedef enum _DAC_OP_TYPE_ {
|
||||
DAC_POLL_TYPE = 0x0,
|
||||
DAC_DMA_TYPE = 0x1,
|
||||
DAC_INTR_TYPE = 0x2,
|
||||
}DAC_OP_TYPE, *PDAC_OP_TYPE;
|
||||
|
||||
// DAC device status
|
||||
typedef enum _DAC_Device_STATUS_ {
|
||||
DAC_STS_UNINITIAL = 0x00,
|
||||
DAC_STS_INITIALIZED = 0x01,
|
||||
DAC_STS_IDLE = 0x02,
|
||||
|
||||
DAC_STS_TX_READY = 0x03,
|
||||
DAC_STS_TX_ING = 0x04,
|
||||
|
||||
DAC_STS_RX_READY = 0x05,
|
||||
DAC_STS_RX_ING = 0x06,
|
||||
|
||||
DAC_STS_ERROR = 0x07,
|
||||
}DAC_Device_STATUS, *PDAC_Device_STATUS;
|
||||
|
||||
//DAC device error type
|
||||
typedef enum _DAC_ERR_TYPE_ {
|
||||
DAC_ERR_FIFO_OVER = 0x04, //DAC FIFO overflow.
|
||||
DAC_ERR_FIFO_STOP = 0x08, //DAC FIFO is completely empty, and it will be stopped automatically.
|
||||
DAC_ERR_FIFO_WRFAIL = 0x10, //When DAC is NOT enabled, a write operation attempts to access DAC register.
|
||||
DAC_ERR_FIFO_DSC_OVER0 = 0x20,
|
||||
DAC_ERR_FIFO_DSC_OVER1 = 0x40,
|
||||
}DAC_ERR_TYPE, *PDAC_ERR_TYPE;
|
||||
|
||||
// DAC data input method
|
||||
typedef enum _DAC_INPUT_TYPE_{
|
||||
DAC_INPUT_SINGLE_WR = 0x1, //DAC input by using single register write
|
||||
DAC_INPUT_DMA_ONEBLK = 0x2, //DAC input by using single DMA block
|
||||
DAC_INPUT_DMA_LLP = 0x3, //DAC input by using DMA linked list mode
|
||||
}DAC_INPUT_TYPE,*PDAC_INPUT_TYPE;
|
||||
|
||||
|
||||
|
||||
|
||||
//======================================================
|
||||
// DAC HAL initial data structure
|
||||
typedef struct _HAL_DAC_INIT_DAT_ {
|
||||
uint8_t DACIdx; //DAC index used
|
||||
uint8_t DACEn; //DAC module enable
|
||||
uint8_t DACDataRate; //DAC data rate, 1'b0:10KHz, 1'b1:250KHz
|
||||
uint8_t DACEndian; //DAC endian selection,
|
||||
//but actually it's for 32-bit DAC data swap control
|
||||
//1'b0: no swap,
|
||||
//1'b1: swap the upper 16-bit and the lower 16-bit
|
||||
uint8_t DACFilterSet; //DAC filter settle
|
||||
uint8_t DACBurstSz; //DAC burst size
|
||||
uint8_t DACDbgSel; //DAC debug sel
|
||||
uint8_t DACDscDbgSel; //DAC debug dsc sel
|
||||
|
||||
uint8_t DACBPDsc; //DAC bypass delta sigma for loopback
|
||||
uint8_t DACDeltaSig; //DAC bypass value of delta sigma
|
||||
uint16_t RSVD1;
|
||||
|
||||
|
||||
|
||||
uint32_t *DACData; //DAC data pointer
|
||||
uint32_t DACPWCtrl; //DAC0 and DAC1 power control
|
||||
uint32_t DACAnaCtrl0; //DAC anapar_da control 0
|
||||
uint32_t DACAnaCtrl1; //DAC anapar_da control 1
|
||||
uint32_t DACIntrMSK; //DAC Interrupt Mask
|
||||
}HAL_DAC_INIT_DAT,*PHAL_DAC_INIT_DAT;
|
||||
|
||||
// DAC HAL Operations
|
||||
typedef struct _HAL_DAC_OP_ {
|
||||
RTK_STATUS (*HalDACInit) (void *Data); //HAL DAC initialization
|
||||
RTK_STATUS (*HalDACDeInit) (void *Data); //HAL DAC de-initialization
|
||||
RTK_STATUS (*HalDACEnable) (void *Data); //HAL DAC de-initialization
|
||||
uint8_t (*HalDACSend) (void *Data); //HAL DAC receive
|
||||
RTK_STATUS (*HalDACIntrCtrl) (void *Data); //HAL DAC interrupt control
|
||||
uint32_t (*HalDACReadReg) (void *Data, uint8_t DACReg);//HAL DAC read register
|
||||
}HAL_DAC_OP, *PHAL_DAC_OP;
|
||||
|
||||
// DAC user callback adapter
|
||||
typedef struct _SAL_DAC_USERCB_ADPT_ {
|
||||
void (*USERCB) (void *Data);
|
||||
uint32_t USERData;
|
||||
}SAL_DAC_USERCB_ADPT, *PSAL_DAC_USERCB_ADPT;
|
||||
|
||||
// DAC user callback structure
|
||||
typedef struct _SAL_DAC_USER_CB_ {
|
||||
PSAL_DAC_USERCB_ADPT pTXCB; //DAC Transmit Callback
|
||||
PSAL_DAC_USERCB_ADPT pTXCCB; //DAC Transmit Complete Callback
|
||||
PSAL_DAC_USERCB_ADPT pRXCB; //DAC Receive Callback
|
||||
PSAL_DAC_USERCB_ADPT pRXCCB; //DAC Receive Complete Callback
|
||||
PSAL_DAC_USERCB_ADPT pRDREQCB; //DAC Read Request Callback
|
||||
PSAL_DAC_USERCB_ADPT pERRCB; //DAC Error Callback
|
||||
PSAL_DAC_USERCB_ADPT pDMATXCB; //DAC DMA Transmit Callback
|
||||
PSAL_DAC_USERCB_ADPT pDMATXCCB; //DAC DMA Transmit Complete Callback
|
||||
PSAL_DAC_USERCB_ADPT pDMARXCB; //DAC DMA Receive Callback
|
||||
PSAL_DAC_USERCB_ADPT pDMARXCCB; //DAC DMA Receive Complete Callback
|
||||
}SAL_DAC_USER_CB, *PSAL_DAC_USER_CB;
|
||||
|
||||
// DAC Transmit Buffer
|
||||
typedef struct _SAL_DAC_TRANSFER_BUF_ {
|
||||
uint32_t DataLen; //DAC Transmfer Length
|
||||
uint32_t *pDataBuf; //DAC Transfer Buffer Pointer
|
||||
uint32_t RSVD; //
|
||||
}SAL_DAC_TRANSFER_BUF,*PSAL_DAC_TRANSFER_BUF;
|
||||
|
||||
typedef struct _SAL_DAC_DMA_USER_DEF_ {
|
||||
|
||||
uint8_t TxDatSrcWdth;
|
||||
uint8_t TxDatDstWdth;
|
||||
uint8_t TxDatSrcBstSz;
|
||||
uint8_t TxDatDstBstSz;
|
||||
|
||||
uint8_t TxChNo;
|
||||
uint8_t LlpCtrl;
|
||||
uint16_t RSVD0;
|
||||
|
||||
uint32_t MaxMultiBlk;
|
||||
uint32_t pLlix;
|
||||
uint32_t pBlockSizeList;
|
||||
}SAL_DAC_DMA_USER_DEF, *PSAL_DAC_DMA_USER_DEF;
|
||||
|
||||
// Software API Level DAC Handler
|
||||
typedef struct _SAL_DAC_HND_ {
|
||||
uint8_t DevNum; //DAC device number
|
||||
uint8_t PinMux; //DAC pin mux seletion
|
||||
uint8_t OpType; //DAC operation type selection
|
||||
volatile uint8_t DevSts; //DAC device status
|
||||
|
||||
uint8_t DACInType; //DAC input type
|
||||
uint8_t RSVD0;
|
||||
uint16_t RSVD1;
|
||||
|
||||
uint32_t DACExd; //DAC extended options:
|
||||
//bit 0: example
|
||||
//bit 31~bit 1: Reserved
|
||||
uint32_t ErrType; //
|
||||
uint32_t TimeOut; //DAC IO Timeout count
|
||||
|
||||
PHAL_DAC_INIT_DAT pInitDat; //Pointer to DAC initial data struct
|
||||
PSAL_DAC_TRANSFER_BUF pTXBuf; //Pointer to DAC TX buffer
|
||||
PSAL_DAC_USER_CB pUserCB; //Pointer to DAC User Callback
|
||||
PSAL_DAC_DMA_USER_DEF pDMAConf; //Pointer to DAC User Define DMA Config
|
||||
}SAL_DAC_HND, *PSAL_DAC_HND;
|
||||
|
||||
// DAC SAL handle private
|
||||
typedef struct _SAL_DAC_HND_PRIV_ {
|
||||
void **ppSalDACHnd; //Pointer to SAL_DAC_HND pointer
|
||||
SAL_DAC_HND SalDACHndPriv; //Private SAL_DAC_HND
|
||||
}SAL_DAC_HND_PRIV, *PSAL_DAC_HND_PRIV;
|
||||
|
||||
//DAC SAL management adapter
|
||||
typedef struct _SAL_DAC_MNGT_ADPT_ {
|
||||
PSAL_DAC_HND_PRIV pSalHndPriv; //Pointer to SAL_DAC_HND
|
||||
PHAL_DAC_INIT_DAT pHalInitDat; //Pointer to HAL DAC initial data( HAL_I2C_INIT_DAT )
|
||||
PHAL_DAC_OP pHalOp; //Pointer to HAL DAC operation( HAL_DAC_OP )
|
||||
void (*pHalOpInit)(void*); //Pointer to HAL DAC initialize function
|
||||
PIRQ_HANDLE pIrqHnd; //Pointer to IRQ handler in SAL layer( IRQ_HANDLE )
|
||||
PSAL_DAC_USER_CB pUserCB; //Pointer to SAL user callbacks (SAL_DAC_USER_CB )
|
||||
void (*pSalIrqFunc)(void*); //Used for SAL DAC interrupt function
|
||||
|
||||
PSAL_DAC_DMA_USER_DEF pDMAConf; //Pointer to DAC User Define DMA config
|
||||
PHAL_GDMA_ADAPTER pHalGdmaAdp;
|
||||
PHAL_GDMA_OP pHalGdmaOp;
|
||||
void (*pHalGdmaOpInit)(void*); //Pointer to HAL DAC initialize function
|
||||
PIRQ_HANDLE pIrqGdmaHnd;
|
||||
void (*pSalDMAIrqFunc)(void*); //Used for SAL DAC interrupt function
|
||||
}SAL_DAC_MNGT_ADPT, *PSAL_DAC_MNGT_ADPT;
|
||||
|
||||
|
||||
//================ DAC HAL Function Prototype ===================
|
||||
// DAC HAL inline function
|
||||
// For checking DAC input index valid or not
|
||||
static inline RTK_STATUS
|
||||
RtkDACIdxChk(
|
||||
IN uint8_t DACIdx
|
||||
)
|
||||
{
|
||||
(void) DACIdx;
|
||||
#if !DAC0_USED
|
||||
if (DACIdx == DAC0_SEL)
|
||||
return _EXIT_FAILURE;
|
||||
#endif
|
||||
|
||||
#if !DAC1_USED
|
||||
if (DACIdx == DAC1_SEL)
|
||||
return _EXIT_FAILURE;
|
||||
#endif
|
||||
|
||||
return _EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
void HalDACOpInit(IN void *Data);
|
||||
RTK_STATUS RtkDACLoadDefault(IN void *Data);
|
||||
RTK_STATUS RtkDACInit(IN void *Data);
|
||||
RTK_STATUS RtkDACDeInit(IN void *Data);
|
||||
RTK_STATUS RtkDACSend(IN void *Data);
|
||||
PSAL_DAC_HND RtkDACGetSalHnd(IN uint8_t DACIdx);
|
||||
RTK_STATUS RtkDACFreeSalHnd(IN PSAL_DAC_HND pSalDACHND);
|
||||
PSAL_DAC_MNGT_ADPT RtkDACGetMngtAdpt(IN uint8_t DACIdx);
|
||||
RTK_STATUS RtkDACFreeMngtAdpt(IN PSAL_DAC_MNGT_ADPT pSalDACMngtAdpt);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _HAL_DIAG_H_
|
||||
#define _HAL_DIAG_H_
|
||||
|
||||
|
||||
//Register offset
|
||||
#define UART_REV_BUF_OFF 0x00
|
||||
#define UART_TRAN_HOLD_OFF 0x00
|
||||
#define UART_DLH_OFF 0x04
|
||||
#define UART_DLL_OFF 0x00
|
||||
#define UART_INTERRUPT_EN_REG_OFF 0x04
|
||||
#define UART_INTERRUPT_IDEN_REG_OFF 0x08
|
||||
#define UART_FIFO_CTL_REG_OFF 0x08
|
||||
#define UART_LINE_CTL_REG_OFF 0x0c
|
||||
#define UART_MODEM_CTL_REG_OFF 0x10
|
||||
#define UART_LINE_STATUS_REG_OFF 0x14
|
||||
#define UART_MODEM_STATUS_REG_OFF 0x18
|
||||
#define UART_FIFO_ACCESS_REG_OFF 0x70
|
||||
#define UART_STATUS_REG_OFF 0x7c
|
||||
#define UART_TFL_OFF 0x80
|
||||
#define UART_RFL_OFF 0x84
|
||||
|
||||
|
||||
//Buad rate
|
||||
#define UART_BAUD_RATE_2400 2400
|
||||
#define UART_BAUD_RATE_4800 4800
|
||||
#define UART_BAUD_RATE_9600 9600
|
||||
#define UART_BAUD_RATE_19200 19200
|
||||
#define UART_BAUD_RATE_38400 38400
|
||||
#define UART_BAUD_RATE_57600 57600
|
||||
#define UART_BAUD_RATE_115200 115200
|
||||
#define UART_BAUD_RATE_921600 921600
|
||||
#define UART_BAUD_RATE_1152000 1152000
|
||||
|
||||
#define UART_PARITY_ENABLE 0x08
|
||||
#define UART_PARITY_DISABLE 0
|
||||
|
||||
#define UART_DATA_LEN_5BIT 0x0
|
||||
#define UART_DATA_LEN_6BIT 0x1
|
||||
#define UART_DATA_LEN_7BIT 0x2
|
||||
#define UART_DATA_LEN_8BIT 0x3
|
||||
|
||||
#define UART_STOP_1BIT 0x0
|
||||
#define UART_STOP_2BIT 0x4
|
||||
|
||||
#ifndef DEFAULT_BAUDRATE
|
||||
#define DEFAULT_BAUDRATE UART_BAUD_RATE_38400
|
||||
#endif
|
||||
|
||||
#define HAL_UART_READ32(addr) HAL_READ32(LOG_UART_REG_BASE, addr)
|
||||
#define HAL_UART_WRITE32(addr, value) HAL_WRITE32(LOG_UART_REG_BASE, addr, value)
|
||||
#define HAL_UART_READ16(addr) HAL_READ16(LOG_UART_REG_BASE, addr)
|
||||
#define HAL_UART_WRITE16(addr, value) HAL_WRITE16(LOG_UART_REG_BASE, addr, value)
|
||||
#define HAL_UART_READ8(addr) HAL_READ8(LOG_UART_REG_BASE, addr)
|
||||
#define HAL_UART_WRITE8(addr, value) HAL_WRITE8(LOG_UART_REG_BASE, addr, value)
|
||||
|
||||
typedef struct _LOG_UART_ADAPTER_ {
|
||||
uint32_t BaudRate;
|
||||
uint32_t FIFOControl;
|
||||
uint32_t IntEnReg;
|
||||
uint8_t Parity;
|
||||
uint8_t Stop;
|
||||
uint8_t DataLength;
|
||||
}LOG_UART_ADAPTER, *PLOG_UART_ADAPTER;
|
||||
|
||||
typedef struct _COMMAND_TABLE_ {
|
||||
const char * cmd;
|
||||
uint16_t ArgvCnt;
|
||||
void (*func)(int argc, char * argv[]);
|
||||
const char * msg;
|
||||
}COMMAND_TABLE, *PCOMMAND_TABLE;
|
||||
|
||||
//void
|
||||
//HalLogUartHandle(void);
|
||||
|
||||
|
||||
extern _LONG_CALL_ROM_ uint32_t
|
||||
HalLogUartInit(
|
||||
IN LOG_UART_ADAPTER UartAdapter
|
||||
);
|
||||
|
||||
|
||||
extern _LONG_CALL_ROM_ void
|
||||
HalSerialPutcRtl8195a(
|
||||
IN uint8_t c
|
||||
);
|
||||
|
||||
extern _LONG_CALL_ROM_ uint8_t
|
||||
HalSerialGetcRtl8195a(
|
||||
IN BOOL PullMode
|
||||
);
|
||||
|
||||
extern _LONG_CALL_ROM_ uint32_t
|
||||
HalSerialGetIsrEnRegRtl8195a(void);
|
||||
|
||||
extern _LONG_CALL_ROM_ void
|
||||
HalSerialSetIrqEnRegRtl8195a (
|
||||
IN uint32_t SetValue
|
||||
);
|
||||
|
||||
|
||||
#endif//_HAL_DIAG_H_
|
||||
|
|
@ -0,0 +1,337 @@
|
|||
/*
|
||||
* Disassemble hal_efuse.o pvvx 10.2016
|
||||
*/
|
||||
#include "rtl8195a.h"
|
||||
#ifdef CONFIG_EFUSE_EN
|
||||
#include "hal_efuse.h"
|
||||
|
||||
//#define NO_ROM_API
|
||||
|
||||
#define EFUSE_WRITE_ENABLE 0
|
||||
|
||||
#define EFUSE_SECTION_SIZE (1<<7) // 128 bytes
|
||||
#define EFUSE_BUF_MAX_LEN (1<<5) // 32 bytes
|
||||
#define OTP_START_ADDR EFUSE_SECTION_SIZE
|
||||
#define OTP_BUF_MAX_LEN (1<<5) // 32 bytes
|
||||
#define EFUSE_SECTION_CODE 11
|
||||
|
||||
#ifdef NO_ROM_API
|
||||
//====================================================== Start libs ROM efuse
|
||||
//----- HalEFUSEPowerSwitch8195AROM addr 0x6561
|
||||
_LONG_CALL_ROM_ int HalEFUSEPowerSwitch8195AROM(IN unsigned char bWrite, IN unsigned char PwrState, IN unsigned char L25OutVoltage) {
|
||||
if (PwrState == 1) {
|
||||
HAL_WRITE32(SYSTEM_CTRL_BASE, REG_SYS_EEPROM_CTRL0, (HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_EEPROM_CTRL0) & 0xFFFFFF) | 0x69000000); // EFUSE_UNLOCK
|
||||
if (!(HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_FUNC_EN) & BIT_SYS_FEN_EELDR)) // REG_SYS_FUNC_EN BIT_SYS_FEN_EELDR ?
|
||||
HAL_WRITE32(SYSTEM_CTRL_BASE, REG_SYS_FUNC_EN, HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_FUNC_EN) | BIT_SYS_FEN_EELDR);
|
||||
if (!(HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_CLK_CTRL0) & BIT_SYSON_CK_EELDR_EN)) // REG_SYS_CLK_CTRL0 BIT_SYSON_CK_EELDR_EN ?
|
||||
HAL_WRITE32(SYSTEM_CTRL_BASE, REG_SYS_CLK_CTRL0, HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_CLK_CTRL0) | BIT_SYSON_CK_EELDR_EN);
|
||||
if (!(HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_CLK_CTRL1) & BIT_PESOC_EELDR_CK_SEL)) // REG_SYS_CLK_CTRL1 BIT_PESOC_EELDR_CK_SEL ?
|
||||
HAL_WRITE32(SYSTEM_CTRL_BASE, REG_SYS_CLK_CTRL1, HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_CLK_CTRL1) | BIT_PESOC_EELDR_CK_SEL);
|
||||
if (bWrite == 1)
|
||||
HAL_WRITE32(SYSTEM_CTRL_BASE, REG_SYS_REGU_CTRL0, (HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_REGU_CTRL0) & 0xFFFFF0FF) | BIT_SYS_REGU_LDO25E_EN | BIT_SYS_REGU_LDO25E_ADJ(L25OutVoltage));
|
||||
}
|
||||
else
|
||||
{
|
||||
HAL_WRITE32(SYSTEM_CTRL_BASE, REG_SYS_EEPROM_CTRL0, HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_EEPROM_CTRL0) & 0xFFFFFF); // EFUSE_UNLOCK
|
||||
if ( bWrite == 1 )
|
||||
HAL_WRITE32(SYSTEM_CTRL_BASE, REG_SYS_REGU_CTRL0, (HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_REGU_CTRL0) & (~BIT_SYS_REGU_LDO25E_EN)));
|
||||
}
|
||||
return bWrite;
|
||||
}
|
||||
|
||||
//----- HALEFUSEOneByteReadROM addr 0x6561
|
||||
_LONG_CALL_ROM_ int HALEFUSEOneByteReadROM(IN unsigned int CtrlSetting, IN unsigned short Addr, OUT unsigned char *Data, IN unsigned char L25OutVoltage)
|
||||
{
|
||||
int i = 0, result = 0;
|
||||
if ( (Addr <= 0xFF) || ((CtrlSetting & 0xFFFF) == 0x26AE) ) {
|
||||
HalEFUSEPowerSwitch8195AROM(1, 1, L25OutVoltage);
|
||||
|
||||
HAL_WRITE32(SYSTEM_CTRL_BASE, REG_SYS_EFUSE_TEST, HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_EFUSE_TEST) & (~BIT_SYS_EF_FORCE_PGMEN));
|
||||
HAL_WRITE32(SYSTEM_CTRL_BASE, REG_SYS_EFUSE_CTRL,
|
||||
(CtrlSetting & (~(BIT_SYS_EF_RWFLAG | (BIT_MASK_SYS_EF_ADDR << BIT_SHIFT_SYS_EF_ADDR) | (BIT_MASK_SYS_EF_DATA << BIT_SHIFT_SYS_EF_DATA))))
|
||||
| BIT_SYS_EF_ADDR(Addr));
|
||||
while(1) {
|
||||
if(HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_EFUSE_CTRL) & BIT_SYS_EF_RWFLAG) {
|
||||
*Data = HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_EFUSE_CTRL);
|
||||
result = 1;
|
||||
break;
|
||||
}
|
||||
HalDelayUs(1000);
|
||||
if (i++ >= 100) {
|
||||
*Data = -1;
|
||||
break;
|
||||
};
|
||||
};
|
||||
HalEFUSEPowerSwitch8195AROM(1, 0, L25OutVoltage);
|
||||
}
|
||||
else *Data = -1;
|
||||
return result;
|
||||
}
|
||||
|
||||
//----- HALEFUSEOneByteWriteROM addr 0x6699
|
||||
_LONG_CALL_ROM_ int HALEFUSEOneByteWriteROM(IN unsigned int CtrlSetting, IN unsigned short Addr, IN unsigned char Data, IN unsigned char L25OutVoltage)
|
||||
{
|
||||
int i = 0, result = 0;
|
||||
if ( (Addr <= 0xFF) || ((CtrlSetting & 0xFFFF) == 0x26AE) ) {
|
||||
HalEFUSEPowerSwitch8195AROM(1, 1, L25OutVoltage);
|
||||
HAL_WRITE32(SYSTEM_CTRL_BASE, REG_SYS_EFUSE_TEST, HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_EFUSE_TEST) | BIT_SYS_EF_FORCE_PGMEN);
|
||||
HAL_WRITE32(SYSTEM_CTRL_BASE, REG_SYS_EFUSE_CTRL, Data | BIT_SYS_EF_RWFLAG | BIT_SYS_EF_ADDR(Addr) | BIT_SYS_EF_DATA(Data) |
|
||||
(CtrlSetting & (~(BIT_SYS_EF_RWFLAG | (BIT_MASK_SYS_EF_ADDR << BIT_SHIFT_SYS_EF_ADDR) | (BIT_MASK_SYS_EF_DATA << BIT_SHIFT_SYS_EF_DATA)))));
|
||||
while(1) {
|
||||
HalDelayUs(1000);
|
||||
if(HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_EFUSE_CTRL) & BIT_SYS_EF_RWFLAG) break;
|
||||
if (i++ >= 100) {
|
||||
result = 1;
|
||||
break;
|
||||
};
|
||||
};
|
||||
HalEFUSEPowerSwitch8195AROM(1, 0, L25OutVoltage);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//====================================================== End libs ROM efuse
|
||||
#endif
|
||||
|
||||
//----- HALOTPOneByteReadRAM
|
||||
int HALOTPOneByteReadRAM(IN unsigned int CtrlSetting, IN unsigned short Addr, OUT unsigned char *Data, IN unsigned char L25OutVoltage)
|
||||
{
|
||||
int result;
|
||||
if ( (unsigned int)(Addr - EFUSE_SECTION_SIZE) > OTP_BUF_MAX_LEN - 1 )
|
||||
result = 1;
|
||||
else
|
||||
result = HALEFUSEOneByteReadROM(CtrlSetting, Addr, Data, L25OutVoltage);
|
||||
return result;
|
||||
}
|
||||
|
||||
//----- HALOTPOneByteWriteRAM
|
||||
int HALOTPOneByteWriteRAM(IN unsigned int CtrlSetting, IN unsigned short Addr, IN unsigned char Data, IN unsigned char L25OutVoltage)
|
||||
{
|
||||
#if EFUSE_WRITE_ENABLE
|
||||
int result;
|
||||
if ( (unsigned int)(Addr - EFUSE_SECTION_SIZE) > OTP_BUF_MAX_LEN - 1 )
|
||||
result = 1;
|
||||
else
|
||||
result = HALEFUSEOneByteWriteROM(CtrlSetting, Addr, Data, L25OutVoltage);
|
||||
return result;
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
//----- HALEFUSEOneByteReadRAM
|
||||
int HALEFUSEOneByteReadRAM(IN unsigned int CtrlSetting, IN unsigned short Addr, IN unsigned char *Data, IN unsigned char L25OutVoltage)
|
||||
{
|
||||
int result;
|
||||
|
||||
if ( (unsigned int)(Addr - 160) > 0x33 )
|
||||
{
|
||||
result = HALEFUSEOneByteReadROM(CtrlSetting, Addr, Data, L25OutVoltage);
|
||||
}
|
||||
else
|
||||
{
|
||||
*Data = -1;
|
||||
result = 1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//----- HALEFUSEOneByteWriteRAM
|
||||
int HALEFUSEOneByteWriteRAM(IN unsigned int CtrlSetting, IN unsigned short Addr, IN unsigned char Data, IN unsigned char L25OutVoltage)
|
||||
{
|
||||
#if EFUSE_WRITE_ENABLE
|
||||
int result;
|
||||
if ( (unsigned int)(Addr - 127) <= 0x54 )
|
||||
result = 1;
|
||||
else {
|
||||
result = HALEFUSEOneByteWriteROM(CtrlSetting, Addr, Data, L25OutVoltage);
|
||||
}
|
||||
return result;
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
//----- ReadEfuseContant
|
||||
void ReadEfuseContant(IN unsigned char UserCode, IN unsigned char *pContant)
|
||||
{
|
||||
unsigned int i, offset, bcnt, eFuse_Addr = 0;
|
||||
unsigned char DataTemp0;
|
||||
unsigned char DataTemp1;
|
||||
unsigned char * pbuf = pContant;
|
||||
|
||||
do {
|
||||
HALEFUSEOneByteReadRAM(HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_EFUSE_CTRL), eFuse_Addr, &DataTemp0, L25EOUTVOLTAGE);
|
||||
if (DataTemp0 == 0x0FF) break;
|
||||
if ((DataTemp0 & 0x0F) == 0x0F) {
|
||||
HALEFUSEOneByteReadRAM(HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_EFUSE_CTRL), ++eFuse_Addr, &DataTemp1, L25EOUTVOLTAGE);
|
||||
offset = ((DataTemp1 & 0x0F0) | (DataTemp0 >> 4)) >> 1;
|
||||
bcnt = (~DataTemp1) & 0x0F;
|
||||
if (((UserCode + EFUSE_SECTION_CODE) << 2) > offset || offset >= ((UserCode + EFUSE_SECTION_CODE + 1) << 2)) {
|
||||
while(bcnt) {
|
||||
if (bcnt & 1) eFuse_Addr += 2;
|
||||
bcnt >>= 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
int base = (offset - ((EFUSE_SECTION_CODE + UserCode) << 2)) << 3;
|
||||
i = 0;
|
||||
while(bcnt) {
|
||||
if (bcnt & 1) {
|
||||
HALEFUSEOneByteReadRAM(HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_EFUSE_CTRL), ++eFuse_Addr, &pbuf[base + i], L25EOUTVOLTAGE);
|
||||
HALEFUSEOneByteReadRAM(HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_EFUSE_CTRL), ++eFuse_Addr, &pbuf[base + i + 1], L25EOUTVOLTAGE);
|
||||
}
|
||||
bcnt >>= 1;
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
else for(i = (~DataTemp0) & 0x0F; i; i >>= 1) if (i & 1) eFuse_Addr += 2;
|
||||
eFuse_Addr++;
|
||||
}
|
||||
while(eFuse_Addr < EFUSE_SECTION_SIZE - 1);
|
||||
}
|
||||
|
||||
//----- ReadEfuseContant1
|
||||
void ReadEfuseContant1(OUT unsigned char *pContant)
|
||||
{
|
||||
ReadEfuseContant(0, pContant);
|
||||
}
|
||||
|
||||
//----- ReadEfuseContant2
|
||||
void ReadEfuseContant2(OUT unsigned char *pContant)
|
||||
{
|
||||
ReadEfuseContant(1, pContant);
|
||||
}
|
||||
|
||||
//----- ReadEfuseContant3
|
||||
void ReadEfuseContant3(OUT unsigned char *pContant)
|
||||
{
|
||||
ReadEfuseContant(2, pContant);
|
||||
}
|
||||
|
||||
//----- GetRemainingEfuseLength
|
||||
int GetRemainingEfuseLength(void)
|
||||
{
|
||||
unsigned int i, eFuse_Addr = 0;
|
||||
unsigned char DataTemp0;
|
||||
do
|
||||
{
|
||||
HALEFUSEOneByteReadRAM(HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_EFUSE_CTRL), eFuse_Addr, &DataTemp0, L25EOUTVOLTAGE);
|
||||
if(DataTemp0 == 0x0FF) break;
|
||||
if((DataTemp0 & 0x0F) == 0x0F)
|
||||
HALEFUSEOneByteReadRAM(HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_EFUSE_CTRL), ++eFuse_Addr, &DataTemp0, L25EOUTVOLTAGE);
|
||||
for (i = (~DataTemp0) & 0x0F; i; i >>= 1 ) if (i & 1) eFuse_Addr += 2;
|
||||
eFuse_Addr++;
|
||||
}
|
||||
while(eFuse_Addr < EFUSE_SECTION_SIZE - 1);
|
||||
return (EFUSE_SECTION_SIZE - 1 - eFuse_Addr);
|
||||
}
|
||||
|
||||
//----- WriteEfuseContant
|
||||
int WriteEfuseContant(IN unsigned char UserCode, IN unsigned char CodeWordNum, IN unsigned char WordEnable, IN unsigned char *pContant)
|
||||
{
|
||||
#if EFUSE_WRITE_ENABLE
|
||||
int result = 0;
|
||||
unsigned int i, j, eFuse_Addr; // r4@3
|
||||
unsigned char DataTemp0;
|
||||
unsigned int bmask = WordEnable & 0xF;
|
||||
|
||||
if (bmask) {
|
||||
eFuse_Addr = 0;
|
||||
do { // eFuse_Addr = 128 - _GetRemainingEfuseLength
|
||||
HALEFUSEOneByteReadRAM(HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_EFUSE_CTRL), eFuse_Addr, &DataTemp0, L25EOUTVOLTAGE);
|
||||
if (DataTemp0 == 0x0ff) break;
|
||||
if ((DataTemp0 & 0x0F) == 0x0F)
|
||||
HALEFUSEOneByteReadRAM(HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_EFUSE_CTRL), ++eFuse_Addr, &DataTemp0, L25EOUTVOLTAGE);
|
||||
for (i = (~DataTemp0) & 0x0F; i; i >>= 1) if (i & 1) eFuse_Addr += 2;
|
||||
eFuse_Addr++;
|
||||
}
|
||||
while (eFuse_Addr <= EFUSE_SECTION_SIZE - 2);
|
||||
|
||||
j = 0;
|
||||
do
|
||||
{
|
||||
if (bmask & 1) j += 2;
|
||||
bmask >>= 1;
|
||||
}
|
||||
while (bmask);
|
||||
if ((eFuse_Addr + j) <= EFUSE_SECTION_SIZE - 4)
|
||||
{
|
||||
HALEFUSEOneByteWriteRAM(HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_EFUSE_CTRL), eFuse_Addr, (((UserCode + EFUSE_SECTION_CODE) << 7) | 0x0F) + ((CodeWordNum & 3) << 5), L25EOUTVOLTAGE);
|
||||
HALEFUSEOneByteWriteRAM(HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_EFUSE_CTRL), eFuse_Addr + 1, (((UserCode + EFUSE_SECTION_CODE) << 3) & 0xF0) | ((~bmask) & 0xF), L25EOUTVOLTAGE);
|
||||
i = 0;
|
||||
while (i < j)
|
||||
{
|
||||
HALEFUSEOneByteWriteRAM(HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_EFUSE_CTRL), eFuse_Addr + 2 + i, pContant[i], L25EOUTVOLTAGE);
|
||||
i++;
|
||||
}
|
||||
result = 1;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
//----- WriteEfuseContant1
|
||||
int WriteEfuseContant1(IN unsigned char CodeWordNum, IN unsigned char WordEnable, IN unsigned char *pContant)
|
||||
{
|
||||
#if EFUSE_WRITE_ENABLE
|
||||
return WriteEfuseContant(0, CodeWordNum, WordEnable, pContant);
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
//----- WriteEfuseContant2
|
||||
int WriteEfuseContant2(IN unsigned char CodeWordNum, IN unsigned char WordEnable, IN unsigned char *pContant)
|
||||
{
|
||||
#if EFUSE_WRITE_ENABLE
|
||||
return WriteEfuseContant(1, CodeWordNum, WordEnable, pContant);
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
//----- WriteEfuseContant2
|
||||
int WriteEfuseContant3(IN unsigned char CodeWordNum, IN unsigned char WordEnable, IN unsigned char *pContant)
|
||||
{
|
||||
#if EFUSE_WRITE_ENABLE
|
||||
return WriteEfuseContant(2, CodeWordNum, WordEnable, pContant);
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
//----- ReadEOTPContant
|
||||
void ReadEOTPContant(IN unsigned char *pContant)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < OTP_BUF_MAX_LEN; i++ )
|
||||
HALOTPOneByteReadRAM(HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_EFUSE_CTRL), i+EFUSE_SECTION_SIZE, &pContant[i], L25EOUTVOLTAGE);
|
||||
}
|
||||
|
||||
//----- WriteEOTPContant
|
||||
void WriteEOTPContant(IN unsigned char *pContant)
|
||||
{
|
||||
#if EFUSE_WRITE_ENABLE
|
||||
int i;
|
||||
unsigned char DataTemp0;
|
||||
for(i = 0; i < OTP_BUF_MAX_LEN; i++ ) {
|
||||
HALOTPOneByteReadRAM(HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_EFUSE_CTRL), i+EFUSE_SECTION_SIZE, &DataTemp0, L25EOUTVOLTAGE);
|
||||
if (DataTemp0 == 0xFF)
|
||||
HALOTPOneByteWriteRAM(HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_EFUSE_CTRL), i+EFUSE_SECTION_SIZE, pContant[i], L25EOUTVOLTAGE);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//----- HALJtagOff
|
||||
void HALJtagOff(void)
|
||||
{
|
||||
#if EFUSE_WRITE_ENABLE
|
||||
HALEFUSEOneByteWriteROM(HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_EFUSE_CTRL), 211, 0xFE, L25EOUTVOLTAGE);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif //CONFIG_EFUSE_EN
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
* hal_efuse.h
|
||||
*/
|
||||
|
||||
#ifndef _HAL_EFUSE_H_
|
||||
#define _HAL_EFUSE_H_
|
||||
|
||||
_LONG_CALL_ROM_ extern void HalEFUSEPowerSwitch8195AROM(IN uint8_t bWrite, IN uint8_t PwrState, IN uint8_t L25OutVoltage);
|
||||
_LONG_CALL_ROM_ extern uint32_t HALEFUSEOneByteReadROM(IN uint32_t CtrlSetting, IN uint16_t Addr, OUT uint8_t *Data, IN uint8_t L25OutVoltage);
|
||||
_LONG_CALL_ROM_ extern uint32_t HALEFUSEOneByteWriteROM(IN uint32_t CtrlSetting, IN uint16_t Addr, IN uint8_t Data, IN uint8_t L25OutVoltage);
|
||||
|
||||
int HALOTPOneByteReadRAM(IN unsigned int CtrlSetting, IN unsigned short Addr, OUT unsigned char *Data, IN unsigned char L25OutVoltage);
|
||||
int HALOTPOneByteWriteRAM(IN unsigned int CtrlSetting, IN unsigned short Addr, IN unsigned char Data, IN unsigned char L25OutVoltage);
|
||||
int HALEFUSEOneByteReadRAM(IN unsigned int CtrlSetting, IN unsigned short Addr, IN unsigned char *Data, IN unsigned char L25OutVoltage);
|
||||
int HALEFUSEOneByteWriteRAM(IN unsigned int CtrlSetting, IN unsigned short Addr, IN unsigned char Data, IN unsigned char L25OutVoltage);
|
||||
|
||||
|
||||
void ReadEfuseContant(IN unsigned char UserCode, OUT unsigned char *pContant);
|
||||
void ReadEfuseContant1(OUT unsigned char *pContant);
|
||||
void ReadEfuseContant2(OUT unsigned char *pContant);
|
||||
void ReadEfuseContant3(OUT unsigned char *pContant);
|
||||
int GetRemainingEfuseLength(void);
|
||||
|
||||
int WriteEfuseContant(IN unsigned char UserCode, IN unsigned char CodeWordNum, IN unsigned char WordEnable, unsigned char *pContant);
|
||||
int WriteEfuseContant1(IN unsigned char CodeWordNum, IN unsigned char WordEnable, IN unsigned char *pContant);
|
||||
int WriteEfuseContant2(IN unsigned char CodeWordNum, IN unsigned char WordEnable, IN unsigned char *pContant);
|
||||
int WriteEfuseContant3(IN unsigned char CodeWordNum, IN unsigned char WordEnable, IN unsigned char *pContant);
|
||||
|
||||
void ReadEOTPContant(IN unsigned char *pContant);
|
||||
void WriteEOTPContant(OUT unsigned char *pContant);
|
||||
void HALJtagOff(void);
|
||||
|
||||
#define EFUSERead8 HALEFUSEOneByteReadRAM
|
||||
#define EFUSEWrite8 HALEFUSEOneByteWriteRAM
|
||||
|
||||
#define L25EOUTVOLTAGE 7
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,578 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
|
||||
#include "rtl8195a.h"
|
||||
#include "hal_gdma.h"
|
||||
|
||||
#ifdef CONFIG_GDMA_EN
|
||||
|
||||
#define MAX_GDMA_INDX 1
|
||||
#define MAX_GDMA_CHNL 6
|
||||
|
||||
static uint8_t HalGdmaReg[MAX_GDMA_INDX+1];
|
||||
|
||||
const HAL_GDMA_CHNL GDMA_Chnl_Option[] = {
|
||||
{0,0,GDMA0_CHANNEL0_IRQ,0},
|
||||
{1,0,GDMA1_CHANNEL0_IRQ,0},
|
||||
{0,1,GDMA0_CHANNEL1_IRQ,0},
|
||||
{1,1,GDMA1_CHANNEL1_IRQ,0},
|
||||
{0,2,GDMA0_CHANNEL2_IRQ,0},
|
||||
{1,2,GDMA1_CHANNEL2_IRQ,0},
|
||||
{0,3,GDMA0_CHANNEL3_IRQ,0},
|
||||
{1,3,GDMA1_CHANNEL3_IRQ,0},
|
||||
{0,4,GDMA0_CHANNEL4_IRQ,0},
|
||||
{1,4,GDMA1_CHANNEL4_IRQ,0},
|
||||
{0,5,GDMA0_CHANNEL5_IRQ,0},
|
||||
{1,5,GDMA1_CHANNEL5_IRQ,0},
|
||||
|
||||
{0xff,0,0,0} // end
|
||||
};
|
||||
|
||||
const HAL_GDMA_CHNL GDMA_Multi_Block_Chnl_Option[] = {
|
||||
{0,4,GDMA0_CHANNEL4_IRQ,0},
|
||||
{1,4,GDMA1_CHANNEL4_IRQ,0},
|
||||
{0,5,GDMA0_CHANNEL5_IRQ,0},
|
||||
{1,5,GDMA1_CHANNEL5_IRQ,0},
|
||||
|
||||
{0xff,0,0,0} // end
|
||||
};
|
||||
|
||||
|
||||
const uint16_t HalGdmaChnlEn[6] = {
|
||||
GdmaCh0, GdmaCh1, GdmaCh2, GdmaCh3,
|
||||
GdmaCh4, GdmaCh5
|
||||
};
|
||||
|
||||
|
||||
|
||||
void HalGdmaOpInit(
|
||||
IN void *Data
|
||||
)
|
||||
{
|
||||
PHAL_GDMA_OP pHalGdmaOp = (PHAL_GDMA_OP) Data;
|
||||
|
||||
pHalGdmaOp->HalGdmaOnOff = HalGdmaOnOffRtl8195a;
|
||||
pHalGdmaOp->HalGdamChInit = HalGdamChInitRtl8195a;
|
||||
pHalGdmaOp->HalGdmaChDis = HalGdmaChDisRtl8195a;
|
||||
pHalGdmaOp->HalGdmaChEn = HalGdmaChEnRtl8195a;
|
||||
pHalGdmaOp->HalGdmaChSeting = HalGdmaChSetingRtl8195a;
|
||||
#ifndef CONFIG_CHIP_E_CUT
|
||||
pHalGdmaOp->HalGdmaChBlockSeting = HalGdmaChBlockSetingRtl8195a_Patch;
|
||||
#else
|
||||
pHalGdmaOp->HalGdmaChBlockSeting = HalGdmaChBlockSetingRtl8195a_V04;
|
||||
#endif
|
||||
pHalGdmaOp->HalGdmaChIsrEnAndDis = HalGdmaChIsrEnAndDisRtl8195a;
|
||||
pHalGdmaOp->HalGdmaChIsrClean = HalGdmaChIsrCleanRtl8195a;
|
||||
pHalGdmaOp->HalGdmaChCleanAutoSrc = HalGdmaChCleanAutoSrcRtl8195a;
|
||||
pHalGdmaOp->HalGdmaChCleanAutoDst = HalGdmaChCleanAutoDstRtl8195a;
|
||||
}
|
||||
|
||||
void HalGdmaOn(PHAL_GDMA_ADAPTER pHalGdmaAdapter)
|
||||
{
|
||||
pHalGdmaAdapter->GdmaOnOff = ON;
|
||||
HalGdmaOnOffRtl8195a((void*)pHalGdmaAdapter);
|
||||
}
|
||||
|
||||
void HalGdmaOff(PHAL_GDMA_ADAPTER pHalGdmaAdapter)
|
||||
{
|
||||
pHalGdmaAdapter->GdmaOnOff = OFF;
|
||||
HalGdmaOnOffRtl8195a((void*)pHalGdmaAdapter);
|
||||
}
|
||||
|
||||
BOOL HalGdmaChInit(PHAL_GDMA_ADAPTER pHalGdmaAdapter)
|
||||
{
|
||||
return (HalGdamChInitRtl8195a((void*)pHalGdmaAdapter));
|
||||
}
|
||||
|
||||
void HalGdmaChDis(PHAL_GDMA_ADAPTER pHalGdmaAdapter)
|
||||
{
|
||||
HalGdmaChDisRtl8195a((void*)pHalGdmaAdapter);
|
||||
}
|
||||
|
||||
void HalGdmaChEn(PHAL_GDMA_ADAPTER pHalGdmaAdapter)
|
||||
{
|
||||
HalGdmaChEnRtl8195a((void*)pHalGdmaAdapter);
|
||||
}
|
||||
|
||||
BOOL HalGdmaChSeting(PHAL_GDMA_ADAPTER pHalGdmaAdapter)
|
||||
{
|
||||
return (HalGdmaChSetingRtl8195a((void*)pHalGdmaAdapter));
|
||||
}
|
||||
|
||||
BOOL HalGdmaChBlockSeting(PHAL_GDMA_ADAPTER pHalGdmaAdapter)
|
||||
{
|
||||
#ifndef CONFIG_CHIP_E_CUT
|
||||
return (HalGdmaChBlockSetingRtl8195a_Patch((void*)pHalGdmaAdapter));
|
||||
#else
|
||||
return (HalGdmaChBlockSetingRtl8195a_V04((void*)pHalGdmaAdapter));
|
||||
#endif
|
||||
}
|
||||
|
||||
void HalGdmaChIsrEn(PHAL_GDMA_ADAPTER pHalGdmaAdapter)
|
||||
{
|
||||
pHalGdmaAdapter->IsrCtrl = ENABLE;
|
||||
HalGdmaChIsrEnAndDisRtl8195a((void*)pHalGdmaAdapter);
|
||||
}
|
||||
|
||||
void HalGdmaChIsrDis(PHAL_GDMA_ADAPTER pHalGdmaAdapter)
|
||||
{
|
||||
pHalGdmaAdapter->IsrCtrl = DISABLE;
|
||||
HalGdmaChIsrEnAndDisRtl8195a((void*)pHalGdmaAdapter);
|
||||
}
|
||||
|
||||
uint8_t HalGdmaChIsrClean(PHAL_GDMA_ADAPTER pHalGdmaAdapter)
|
||||
{
|
||||
return (HalGdmaChIsrCleanRtl8195a((void*)pHalGdmaAdapter));
|
||||
}
|
||||
|
||||
void HalGdmaChCleanAutoSrc(PHAL_GDMA_ADAPTER pHalGdmaAdapter)
|
||||
{
|
||||
HalGdmaChCleanAutoSrcRtl8195a((void*)pHalGdmaAdapter);
|
||||
}
|
||||
|
||||
void HalGdmaChCleanAutoDst(PHAL_GDMA_ADAPTER pHalGdmaAdapter)
|
||||
{
|
||||
HalGdmaChCleanAutoDstRtl8195a((void*)pHalGdmaAdapter);
|
||||
}
|
||||
|
||||
HAL_Status HalGdmaChnlRegister (uint8_t GdmaIdx, uint8_t ChnlNum)
|
||||
{
|
||||
uint32_t mask;
|
||||
|
||||
if ((GdmaIdx > MAX_GDMA_INDX) || (ChnlNum > MAX_GDMA_CHNL)) {
|
||||
// Invalid GDMA Index or Channel Number
|
||||
return HAL_ERR_PARA;
|
||||
}
|
||||
|
||||
mask = 1 << ChnlNum;
|
||||
|
||||
if ((HalGdmaReg[GdmaIdx] & mask) != 0) {
|
||||
return HAL_BUSY;
|
||||
}
|
||||
else {
|
||||
#if 1
|
||||
if (HalGdmaReg[GdmaIdx] == 0) {
|
||||
if (GdmaIdx == 0) {
|
||||
ACTCK_GDMA0_CCTRL(ON);
|
||||
GDMA0_FCTRL(ON);
|
||||
}
|
||||
else {
|
||||
ACTCK_GDMA1_CCTRL(ON);
|
||||
GDMA1_FCTRL(ON);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
HalGdmaReg[GdmaIdx] |= mask;
|
||||
return HAL_OK;
|
||||
}
|
||||
}
|
||||
|
||||
void HalGdmaChnlUnRegister (uint8_t GdmaIdx, uint8_t ChnlNum)
|
||||
{
|
||||
uint32_t mask;
|
||||
|
||||
if ((GdmaIdx > MAX_GDMA_INDX) || (ChnlNum > MAX_GDMA_CHNL)) {
|
||||
// Invalid GDMA Index or Channel Number
|
||||
return;
|
||||
}
|
||||
|
||||
mask = 1 << ChnlNum;
|
||||
|
||||
HalGdmaReg[GdmaIdx] &= ~mask;
|
||||
#if 1
|
||||
if (HalGdmaReg[GdmaIdx] == 0) {
|
||||
if (GdmaIdx == 0) {
|
||||
ACTCK_GDMA0_CCTRL(OFF);
|
||||
GDMA0_FCTRL(OFF);
|
||||
}
|
||||
else {
|
||||
ACTCK_GDMA1_CCTRL(OFF);
|
||||
GDMA1_FCTRL(OFF);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
PHAL_GDMA_CHNL HalGdmaChnlAlloc (HAL_GDMA_CHNL *pChnlOption)
|
||||
{
|
||||
HAL_GDMA_CHNL *pgdma_chnl;
|
||||
|
||||
pgdma_chnl = pChnlOption;
|
||||
if (pChnlOption == NULL) {
|
||||
// Use default GDMA Channel Option table
|
||||
pgdma_chnl = (HAL_GDMA_CHNL*)&GDMA_Chnl_Option[0];
|
||||
}
|
||||
else{
|
||||
pgdma_chnl = (HAL_GDMA_CHNL*) pgdma_chnl;
|
||||
}
|
||||
|
||||
while (pgdma_chnl->GdmaIndx <= MAX_GDMA_INDX) {
|
||||
if (HalGdmaChnlRegister(pgdma_chnl->GdmaIndx, pgdma_chnl->GdmaChnl) == HAL_OK) {
|
||||
// This GDMA Channel is available
|
||||
break;
|
||||
}
|
||||
pgdma_chnl += 1;
|
||||
}
|
||||
|
||||
if (pgdma_chnl->GdmaIndx > MAX_GDMA_INDX) {
|
||||
pgdma_chnl = NULL;
|
||||
}
|
||||
|
||||
return pgdma_chnl;
|
||||
}
|
||||
|
||||
void HalGdmaChnlFree (HAL_GDMA_CHNL *pChnl)
|
||||
{
|
||||
IRQ_HANDLE IrqHandle;
|
||||
|
||||
IrqHandle.IrqNum = pChnl->IrqNum;
|
||||
InterruptDis(&IrqHandle);
|
||||
InterruptUnRegister(&IrqHandle);
|
||||
HalGdmaChnlUnRegister(pChnl->GdmaIndx, pChnl->GdmaChnl);
|
||||
}
|
||||
|
||||
void HalGdmaMemIrqHandler(void *pData)
|
||||
{
|
||||
PHAL_GDMA_OBJ pHalGdmaObj=(PHAL_GDMA_OBJ)pData;
|
||||
PHAL_GDMA_ADAPTER pHalGdmaAdapter;
|
||||
PIRQ_HANDLE pGdmaIrqHandle;
|
||||
|
||||
pHalGdmaAdapter = &(pHalGdmaObj->HalGdmaAdapter);
|
||||
pGdmaIrqHandle = &(pHalGdmaObj->GdmaIrqHandle);
|
||||
// Clean Auto Reload Bit
|
||||
HalGdmaChCleanAutoDst((void*)pHalGdmaAdapter);
|
||||
|
||||
// Clear Pending ISR
|
||||
HalGdmaChIsrClean((void*)pHalGdmaAdapter);
|
||||
|
||||
HalGdmaChDis((void*)(pHalGdmaAdapter));
|
||||
pHalGdmaObj->Busy = 0;
|
||||
|
||||
if (pGdmaIrqHandle->IrqFun != NULL) {
|
||||
pGdmaIrqHandle->IrqFun((void*)pGdmaIrqHandle->Data);
|
||||
}
|
||||
}
|
||||
|
||||
BOOL HalGdmaMemCpyAggrInit(PHAL_GDMA_OBJ pHalGdmaObj)
|
||||
{
|
||||
HAL_GDMA_CHNL *pgdma_chnl;
|
||||
PHAL_GDMA_ADAPTER pHalGdmaAdapter;
|
||||
PIRQ_HANDLE pGdmaIrqHandle;
|
||||
IRQ_HANDLE IrqHandle;
|
||||
|
||||
pgdma_chnl = HalGdmaChnlAlloc((PHAL_GDMA_CHNL) &GDMA_Multi_Block_Chnl_Option[0]); // get a whatever GDMA channel
|
||||
if (NULL == pgdma_chnl) {
|
||||
DBG_GDMA_ERR("%s: Cannot allocate a GDMA Channel\n", __FUNCTION__);
|
||||
return _FALSE;
|
||||
}
|
||||
|
||||
pHalGdmaAdapter = &(pHalGdmaObj->HalGdmaAdapter);
|
||||
pGdmaIrqHandle = &(pHalGdmaObj->GdmaIrqHandle);
|
||||
|
||||
DBG_GDMA_INFO("%s: Use GDMA%d CH%d\n", __FUNCTION__, pgdma_chnl->GdmaIndx, pgdma_chnl->GdmaChnl);
|
||||
|
||||
_memset((void *)pHalGdmaAdapter, 0, sizeof(HAL_GDMA_ADAPTER));
|
||||
|
||||
pHalGdmaAdapter->GdmaCtl.TtFc = TTFCMemToMem;
|
||||
pHalGdmaAdapter->GdmaCtl.Done = 1;
|
||||
pHalGdmaAdapter->MuliBlockCunt = 0;
|
||||
pHalGdmaAdapter->MaxMuliBlock = 1;
|
||||
pHalGdmaAdapter->ChNum = pgdma_chnl->GdmaChnl;
|
||||
pHalGdmaAdapter->GdmaIndex = pgdma_chnl->GdmaIndx;
|
||||
pHalGdmaAdapter->ChEn = 0x0101 << pgdma_chnl->GdmaChnl;
|
||||
pHalGdmaAdapter->GdmaIsrType = (TransferType|ErrType);
|
||||
pHalGdmaAdapter->IsrCtrl = ENABLE;
|
||||
pHalGdmaAdapter->GdmaOnOff = ON;
|
||||
pHalGdmaAdapter->GdmaCtl.IntEn = 1;
|
||||
pHalGdmaAdapter->Rsvd4to7 = 1;
|
||||
pHalGdmaAdapter->Llpctrl = 1;
|
||||
pGdmaIrqHandle->IrqNum = pgdma_chnl->IrqNum;
|
||||
pGdmaIrqHandle->Priority = 10;
|
||||
|
||||
IrqHandle.IrqFun = (IRQ_FUN) HalGdmaMemIrqHandler;
|
||||
IrqHandle.Data = (uint32_t) pHalGdmaObj;
|
||||
IrqHandle.IrqNum = pGdmaIrqHandle->IrqNum;
|
||||
IrqHandle.Priority = pGdmaIrqHandle->Priority;
|
||||
|
||||
InterruptRegister(&IrqHandle);
|
||||
InterruptEn(&IrqHandle);
|
||||
pHalGdmaObj->Busy = 0;
|
||||
|
||||
return _TRUE;
|
||||
}
|
||||
|
||||
|
||||
void HalGdmaMultiBlockSetting(PHAL_GDMA_OBJ pHalGdmaObj, PHAL_GDMA_BLOCK pHalGdmaBlock)
|
||||
{
|
||||
PHAL_GDMA_ADAPTER pHalGdmaAdapter;
|
||||
uint8_t BlockNumber;
|
||||
uint8_t BlockIndex;
|
||||
uint8_t FourBytesAlign;
|
||||
|
||||
BlockNumber = pHalGdmaObj->BlockNum;
|
||||
pHalGdmaAdapter = &(pHalGdmaObj->HalGdmaAdapter);
|
||||
|
||||
pHalGdmaAdapter->GdmaCtl.LlpSrcEn = 1;
|
||||
pHalGdmaAdapter->GdmaCtl.LlpDstEn = 1;
|
||||
|
||||
if(((pHalGdmaBlock[0].SrcAddr & 0x03) == 0) &&((pHalGdmaBlock[0].DstAddr & 0x03) == 0)
|
||||
&& ((pHalGdmaBlock[0].BlockLength & 0X03) == 0)){
|
||||
pHalGdmaAdapter->GdmaCtl.SrcMsize = MsizeEight;
|
||||
pHalGdmaAdapter->GdmaCtl.SrcTrWidth = TrWidthFourBytes;
|
||||
pHalGdmaAdapter->GdmaCtl.DestMsize = MsizeEight;
|
||||
pHalGdmaAdapter->GdmaCtl.DstTrWidth = TrWidthFourBytes;
|
||||
FourBytesAlign = 1;
|
||||
}
|
||||
else{
|
||||
pHalGdmaAdapter->GdmaCtl.SrcMsize = MsizeEight;
|
||||
pHalGdmaAdapter->GdmaCtl.SrcTrWidth = TrWidthOneByte;
|
||||
pHalGdmaAdapter->GdmaCtl.DestMsize = MsizeEight;
|
||||
pHalGdmaAdapter->GdmaCtl.DstTrWidth = TrWidthOneByte;
|
||||
FourBytesAlign = 0;
|
||||
}
|
||||
|
||||
for(BlockIndex = 0; BlockIndex < BlockNumber; BlockIndex++){
|
||||
|
||||
pHalGdmaObj->GdmaChLli[BlockIndex].Sarx = pHalGdmaBlock[BlockIndex].SrcAddr;
|
||||
pHalGdmaObj->GdmaChLli[BlockIndex].Darx = pHalGdmaBlock[BlockIndex].DstAddr;
|
||||
pHalGdmaObj->BlockSizeList[BlockIndex].pNextBlockSiz = &pHalGdmaObj->BlockSizeList[BlockIndex + 1];
|
||||
|
||||
if(FourBytesAlign){
|
||||
pHalGdmaObj->BlockSizeList[BlockIndex].BlockSize = pHalGdmaBlock[BlockIndex].BlockLength >> 2;
|
||||
}
|
||||
else{
|
||||
pHalGdmaObj->BlockSizeList[BlockIndex].BlockSize = pHalGdmaBlock[BlockIndex].BlockLength;
|
||||
}
|
||||
|
||||
pHalGdmaObj->Lli[BlockIndex].pLliEle = (GDMA_CH_LLI_ELE*) &pHalGdmaObj->GdmaChLli[BlockIndex];
|
||||
pHalGdmaObj->Lli[BlockIndex].pNextLli = &pHalGdmaObj->Lli[BlockIndex + 1];
|
||||
|
||||
|
||||
if(BlockIndex == BlockNumber - 1){
|
||||
pHalGdmaObj->BlockSizeList[BlockIndex].pNextBlockSiz = NULL;
|
||||
pHalGdmaObj->Lli[BlockIndex].pNextLli = NULL;
|
||||
}
|
||||
//DBG_GDMA_INFO("Lli[%d].pLiEle = %x\r\n", BlockIndex,Lli[BlockIndex].pLliEle);
|
||||
//DBG_GDMA_INFO("Lli[%d].pNextLli = %x\r\n", BlockIndex,Lli[BlockIndex].pNextLli);
|
||||
}
|
||||
|
||||
pHalGdmaAdapter->pBlockSizeList = (struct BLOCK_SIZE_LIST*) &pHalGdmaObj->BlockSizeList;
|
||||
pHalGdmaAdapter->pLlix = (struct GDMA_CH_LLI*) &pHalGdmaObj->Lli;
|
||||
//DBG_GDMA_INFO("pHalGdmaAdapter->pBlockSizeList = %x\r\n", pHalGdmaAdapter->pBlockSizeList);
|
||||
//DBG_GDMA_INFO("pHalGdmaAdapter->pLlix = %x\r\n", pHalGdmaAdapter->pLlix );
|
||||
}
|
||||
|
||||
void HalGdmaLLPMemAlign(PHAL_GDMA_OBJ pHalGdmaObj, PHAL_GDMA_BLOCK pHalGdmaBlock)
|
||||
{
|
||||
PHAL_GDMA_ADAPTER pHalGdmaAdapter;
|
||||
PGDMA_CH_LLI_ELE pLliEle;
|
||||
struct GDMA_CH_LLI *pGdmaChLli;
|
||||
struct BLOCK_SIZE_LIST *pGdmaChBkLi;
|
||||
uint32_t CtlxLow;
|
||||
uint32_t CtlxUp;
|
||||
uint8_t BlockNumber;
|
||||
uint8_t BlockIndex;
|
||||
|
||||
pHalGdmaAdapter = &(pHalGdmaObj->HalGdmaAdapter);
|
||||
BlockNumber = pHalGdmaObj->BlockNum;
|
||||
|
||||
pLliEle = pHalGdmaAdapter->pLlix->pLliEle;
|
||||
pGdmaChLli = pHalGdmaAdapter->pLlix->pNextLli;
|
||||
pGdmaChBkLi = pHalGdmaAdapter->pBlockSizeList;
|
||||
|
||||
//4 Move to the second block to configure Memory Alginment setting
|
||||
pLliEle->Llpx = (uint32_t) pGdmaChLli->pLliEle;
|
||||
pGdmaChBkLi = pGdmaChBkLi ->pNextBlockSiz;
|
||||
|
||||
for(BlockIndex = 1; BlockIndex < BlockNumber; BlockIndex++){
|
||||
pLliEle = pGdmaChLli->pLliEle;
|
||||
CtlxLow = pLliEle->CtlxLow;
|
||||
CtlxLow &= (BIT_INVC_CTLX_LO_DST_TR_WIDTH & BIT_INVC_CTLX_LO_SRC_TR_WIDTH);
|
||||
CtlxUp = pLliEle->CtlxUp;
|
||||
CtlxUp &= (BIT_INVC_CTLX_UP_BLOCK_BS);
|
||||
|
||||
if(((pHalGdmaBlock[BlockIndex].SrcAddr & 0x03) == 0) &&((pHalGdmaBlock[BlockIndex].DstAddr & 0x03) == 0)
|
||||
&& ((pHalGdmaBlock[BlockIndex].BlockLength & 0X03) == 0)){
|
||||
pHalGdmaAdapter->GdmaCtl.SrcTrWidth = TrWidthFourBytes;
|
||||
pHalGdmaAdapter->GdmaCtl.DstTrWidth = TrWidthFourBytes;
|
||||
pGdmaChBkLi->BlockSize = pHalGdmaBlock[BlockIndex].BlockLength>> 2;
|
||||
|
||||
}
|
||||
else{
|
||||
pHalGdmaAdapter->GdmaCtl.SrcTrWidth = TrWidthOneByte;
|
||||
pHalGdmaAdapter->GdmaCtl.DstTrWidth = TrWidthOneByte;
|
||||
pGdmaChBkLi->BlockSize = pHalGdmaBlock[BlockIndex].BlockLength;
|
||||
}
|
||||
|
||||
CtlxLow |= (BIT_CTLX_LO_DST_TR_WIDTH(pHalGdmaAdapter->GdmaCtl.DstTrWidth) |
|
||||
BIT_CTLX_LO_SRC_TR_WIDTH(pHalGdmaAdapter->GdmaCtl.SrcTrWidth));
|
||||
CtlxUp |= BIT_CTLX_UP_BLOCK_BS(pGdmaChBkLi->BlockSize);
|
||||
|
||||
pGdmaChLli = pGdmaChLli->pNextLli;
|
||||
pGdmaChBkLi = pGdmaChBkLi->pNextBlockSiz;
|
||||
pLliEle->CtlxLow = CtlxLow;
|
||||
pLliEle->CtlxUp = CtlxUp;
|
||||
pLliEle->Llpx = (uint32_t)(pGdmaChLli->pLliEle);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void HalGdmaMemAggr(PHAL_GDMA_OBJ pHalGdmaObj, PHAL_GDMA_BLOCK pHalGdmaBlock)
|
||||
{
|
||||
PHAL_GDMA_ADAPTER pHalGdmaAdapter;
|
||||
|
||||
uint8_t BlockNumber;
|
||||
|
||||
BlockNumber = pHalGdmaObj->BlockNum;
|
||||
pHalGdmaAdapter = &(pHalGdmaObj->HalGdmaAdapter);
|
||||
|
||||
if (pHalGdmaObj->Busy) {
|
||||
DBG_GDMA_ERR("%s: ==> GDMA is Busy\r\n", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
pHalGdmaObj->Busy = 1;
|
||||
|
||||
pHalGdmaAdapter->MaxMuliBlock = BlockNumber;
|
||||
pHalGdmaAdapter->ChSar = pHalGdmaBlock[0].SrcAddr;
|
||||
pHalGdmaAdapter->ChDar = pHalGdmaBlock[0].DstAddr;
|
||||
|
||||
HalGdmaMultiBlockSetting(pHalGdmaObj, pHalGdmaBlock);
|
||||
HalGdmaOn((pHalGdmaAdapter));
|
||||
HalGdmaChIsrEn((pHalGdmaAdapter));
|
||||
HalGdmaChBlockSeting((pHalGdmaAdapter));
|
||||
HalGdmaLLPMemAlign(pHalGdmaObj, pHalGdmaBlock);
|
||||
HalGdmaChEn((pHalGdmaAdapter));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOL HalGdmaMemCpyInit(PHAL_GDMA_OBJ pHalGdmaObj)
|
||||
{
|
||||
HAL_GDMA_CHNL *pgdma_chnl;
|
||||
PHAL_GDMA_ADAPTER pHalGdmaAdapter;
|
||||
PIRQ_HANDLE pGdmaIrqHandle;
|
||||
IRQ_HANDLE IrqHandle;
|
||||
|
||||
pgdma_chnl = HalGdmaChnlAlloc(NULL); // get a whatever GDMA channel
|
||||
if (NULL == pgdma_chnl) {
|
||||
DBG_GDMA_ERR("%s: Cannot allocate a GDMA Channel\n", __FUNCTION__);
|
||||
return _FALSE;
|
||||
}
|
||||
|
||||
pHalGdmaAdapter = &(pHalGdmaObj->HalGdmaAdapter);
|
||||
pGdmaIrqHandle = &(pHalGdmaObj->GdmaIrqHandle);
|
||||
|
||||
DBG_GDMA_INFO("%s: Use GDMA%d CH%d\n", __FUNCTION__, pgdma_chnl->GdmaIndx, pgdma_chnl->GdmaChnl);
|
||||
#if 0
|
||||
if (pgdma_chnl->GdmaIndx == 0) {
|
||||
ACTCK_GDMA0_CCTRL(ON);
|
||||
GDMA0_FCTRL(ON);
|
||||
}
|
||||
else if (pgdma_chnl->GdmaIndx == 1) {
|
||||
ACTCK_GDMA1_CCTRL(ON);
|
||||
GDMA1_FCTRL(ON);
|
||||
}
|
||||
#endif
|
||||
_memset((void *)pHalGdmaAdapter, 0, sizeof(HAL_GDMA_ADAPTER));
|
||||
|
||||
// pHalGdmaAdapter->GdmaCtl.TtFc = TTFCMemToMem;
|
||||
pHalGdmaAdapter->GdmaCtl.Done = 1;
|
||||
// pHalGdmaAdapter->MuliBlockCunt = 0;
|
||||
// pHalGdmaAdapter->MaxMuliBlock = 1;
|
||||
pHalGdmaAdapter->ChNum = pgdma_chnl->GdmaChnl;
|
||||
pHalGdmaAdapter->GdmaIndex = pgdma_chnl->GdmaIndx;
|
||||
pHalGdmaAdapter->ChEn = 0x0101 << pgdma_chnl->GdmaChnl;
|
||||
pHalGdmaAdapter->GdmaIsrType = (TransferType|ErrType);
|
||||
pHalGdmaAdapter->IsrCtrl = ENABLE;
|
||||
pHalGdmaAdapter->GdmaOnOff = ON;
|
||||
|
||||
pHalGdmaAdapter->GdmaCtl.IntEn = 1;
|
||||
// pHalGdmaAdapter->GdmaCtl.SrcMsize = MsizeEight;
|
||||
// pHalGdmaAdapter->GdmaCtl.DestMsize = MsizeEight;
|
||||
// pHalGdmaAdapter->GdmaCtl.SrcTrWidth = TrWidthFourBytes;
|
||||
// pHalGdmaAdapter->GdmaCtl.DstTrWidth = TrWidthFourBytes;
|
||||
// pHalGdmaAdapter->GdmaCtl.Dinc = IncType;
|
||||
// pHalGdmaAdapter->GdmaCtl.Sinc = IncType;
|
||||
|
||||
pGdmaIrqHandle->IrqNum = pgdma_chnl->IrqNum;
|
||||
pGdmaIrqHandle->Priority = 10;
|
||||
|
||||
IrqHandle.IrqFun = (IRQ_FUN) HalGdmaMemIrqHandler;
|
||||
IrqHandle.Data = (uint32_t) pHalGdmaObj;
|
||||
IrqHandle.IrqNum = pGdmaIrqHandle->IrqNum;
|
||||
IrqHandle.Priority = pGdmaIrqHandle->Priority;
|
||||
|
||||
InterruptRegister(&IrqHandle);
|
||||
InterruptEn(&IrqHandle);
|
||||
pHalGdmaObj->Busy = 0;
|
||||
|
||||
return _TRUE;
|
||||
}
|
||||
|
||||
void HalGdmaMemCpyDeInit(PHAL_GDMA_OBJ pHalGdmaObj)
|
||||
{
|
||||
HAL_GDMA_CHNL GdmaChnl;
|
||||
PHAL_GDMA_ADAPTER pHalGdmaAdapter;
|
||||
PIRQ_HANDLE pGdmaIrqHandle;
|
||||
|
||||
pHalGdmaAdapter = &(pHalGdmaObj->HalGdmaAdapter);
|
||||
pGdmaIrqHandle = &(pHalGdmaObj->GdmaIrqHandle);
|
||||
|
||||
GdmaChnl.GdmaIndx = pHalGdmaAdapter->GdmaIndex;
|
||||
GdmaChnl.GdmaChnl = pHalGdmaAdapter->ChNum;
|
||||
GdmaChnl.IrqNum = pGdmaIrqHandle->IrqNum;
|
||||
HalGdmaChnlFree(&GdmaChnl);
|
||||
}
|
||||
|
||||
// If multi-task using the same GDMA Object, then it needs a mutex to protect this procedure
|
||||
void* HalGdmaMemCpy(PHAL_GDMA_OBJ pHalGdmaObj, void* pDest, void* pSrc, uint32_t len)
|
||||
{
|
||||
PHAL_GDMA_ADAPTER pHalGdmaAdapter;
|
||||
|
||||
if (pHalGdmaObj->Busy) {
|
||||
DBG_GDMA_ERR("%s: ==> GDMA is Busy\r\n", __FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
pHalGdmaObj->Busy = 1;
|
||||
pHalGdmaAdapter = &(pHalGdmaObj->HalGdmaAdapter);
|
||||
|
||||
DBG_GDMA_INFO("%s: ==> Src=0x%x Dst=0x%x Len=%d\r\n", __FUNCTION__, pSrc, pDest, len);
|
||||
if ((((uint32_t)pSrc & 0x03)==0) &&
|
||||
(((uint32_t)pDest & 0x03)==0) &&
|
||||
((len & 0x03)== 0)) {
|
||||
// 4-bytes aligned, move 4 bytes each transfer
|
||||
pHalGdmaAdapter->GdmaCtl.SrcMsize = MsizeEight;
|
||||
pHalGdmaAdapter->GdmaCtl.SrcTrWidth = TrWidthFourBytes;
|
||||
pHalGdmaAdapter->GdmaCtl.DestMsize = MsizeEight;
|
||||
pHalGdmaAdapter->GdmaCtl.DstTrWidth = TrWidthFourBytes;
|
||||
pHalGdmaAdapter->GdmaCtl.BlockSize = len >> 2;
|
||||
}
|
||||
else {
|
||||
pHalGdmaAdapter->GdmaCtl.SrcMsize = MsizeEight;
|
||||
pHalGdmaAdapter->GdmaCtl.SrcTrWidth = TrWidthOneByte;
|
||||
pHalGdmaAdapter->GdmaCtl.DestMsize = MsizeEight;
|
||||
pHalGdmaAdapter->GdmaCtl.DstTrWidth = TrWidthOneByte;
|
||||
pHalGdmaAdapter->GdmaCtl.BlockSize = len;
|
||||
}
|
||||
|
||||
pHalGdmaAdapter->ChSar = (uint32_t)pSrc;
|
||||
pHalGdmaAdapter->ChDar = (uint32_t)pDest;
|
||||
pHalGdmaAdapter->PacketLen = len;
|
||||
|
||||
HalGdmaOn((pHalGdmaAdapter));
|
||||
HalGdmaChIsrEn((pHalGdmaAdapter));
|
||||
HalGdmaChSeting((pHalGdmaAdapter));
|
||||
HalGdmaChEn((pHalGdmaAdapter));
|
||||
|
||||
return (pDest);
|
||||
}
|
||||
|
||||
#endif // CONFIG_GDMA_EN
|
||||
|
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _HAL_GDMA_H_
|
||||
#define _HAL_GDMA_H_
|
||||
|
||||
#include "rtl8195a_gdma.h"
|
||||
|
||||
typedef struct _GDMA_CH_LLI_ELE_ {
|
||||
uint32_t Sarx;
|
||||
uint32_t Darx;
|
||||
uint32_t Llpx;
|
||||
uint32_t CtlxLow;
|
||||
uint32_t CtlxUp;
|
||||
uint32_t Temp;
|
||||
}GDMA_CH_LLI_ELE, *PGDMA_CH_LLI_ELE;
|
||||
#if 1
|
||||
#if 0
|
||||
typedef struct _GDMA_CH_LLI_ {
|
||||
PGDMA_CH_LLI_ELE pLliEle;
|
||||
PGDMA_CH_LLI pNextLli;
|
||||
}GDMA_CH_LLI, *PGDMA_CH_LLI;
|
||||
|
||||
typedef struct _BLOCK_SIZE_LIST_ {
|
||||
uint32_t BlockSize;
|
||||
PBLOCK_SIZE_LIST pNextBlockSiz;
|
||||
}BLOCK_SIZE_LIST, *PBLOCK_SIZE_LIST;
|
||||
#else
|
||||
struct GDMA_CH_LLI {
|
||||
PGDMA_CH_LLI_ELE pLliEle;
|
||||
struct GDMA_CH_LLI *pNextLli;
|
||||
};
|
||||
|
||||
struct BLOCK_SIZE_LIST {
|
||||
uint32_t BlockSize;
|
||||
struct BLOCK_SIZE_LIST *pNextBlockSiz;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
typedef struct _HAL_GDMA_ADAPTER_ {
|
||||
uint32_t ChSar;
|
||||
uint32_t ChDar;
|
||||
GDMA_CHANNEL_NUM ChEn;
|
||||
GDMA_CTL_REG GdmaCtl;
|
||||
GDMA_CFG_REG GdmaCfg;
|
||||
uint32_t PacketLen;
|
||||
uint32_t BlockLen;
|
||||
uint32_t MuliBlockCunt;
|
||||
uint32_t MaxMuliBlock;
|
||||
struct GDMA_CH_LLI *pLlix;
|
||||
struct BLOCK_SIZE_LIST *pBlockSizeList;
|
||||
|
||||
PGDMA_CH_LLI_ELE pLli;
|
||||
uint32_t NextPlli;
|
||||
uint8_t TestItem;
|
||||
uint8_t ChNum;
|
||||
uint8_t GdmaIndex;
|
||||
uint8_t IsrCtrl:1;
|
||||
uint8_t GdmaOnOff:1;
|
||||
uint8_t Llpctrl:1;
|
||||
uint8_t Lli0:1;
|
||||
uint8_t Rsvd4to7:4;
|
||||
uint8_t GdmaIsrType;
|
||||
}HAL_GDMA_ADAPTER, *PHAL_GDMA_ADAPTER;
|
||||
|
||||
typedef struct _HAL_GDMA_CHNL_ {
|
||||
uint8_t GdmaIndx;
|
||||
uint8_t GdmaChnl;
|
||||
uint8_t IrqNum;
|
||||
uint8_t Reserved;
|
||||
}HAL_GDMA_CHNL, *PHAL_GDMA_CHNL;
|
||||
|
||||
typedef struct _HAL_GDMA_BLOCK_ {
|
||||
uint32_t SrcAddr;
|
||||
uint32_t DstAddr;
|
||||
uint32_t BlockLength;
|
||||
uint32_t SrcOffset;
|
||||
uint32_t DstOffset;
|
||||
}HAL_GDMA_BLOCK, *PHAL_GDMA_BLOCK;
|
||||
|
||||
typedef struct _HAL_GDMA_OP_ {
|
||||
void (*HalGdmaOnOff)(void *Data);
|
||||
BOOL (*HalGdamChInit)(void *Data);
|
||||
BOOL (*HalGdmaChSeting)(void *Data);
|
||||
BOOL (*HalGdmaChBlockSeting)(void *Data);
|
||||
void (*HalGdmaChDis)(void *Data);
|
||||
void (*HalGdmaChEn)(void *Data);
|
||||
void (*HalGdmaChIsrEnAndDis) (void *Data);
|
||||
uint8_t (*HalGdmaChIsrClean)(void *Data);
|
||||
void (*HalGdmaChCleanAutoSrc)(void *Data);
|
||||
void (*HalGdmaChCleanAutoDst)(void *Data);
|
||||
}HAL_GDMA_OP, *PHAL_GDMA_OP;
|
||||
|
||||
typedef struct _HAL_GDMA_OBJ_ {
|
||||
HAL_GDMA_ADAPTER HalGdmaAdapter;
|
||||
IRQ_HANDLE GdmaIrqHandle;
|
||||
volatile GDMA_CH_LLI_ELE GdmaChLli[16];
|
||||
struct GDMA_CH_LLI Lli[16];
|
||||
struct BLOCK_SIZE_LIST BlockSizeList[16];
|
||||
uint8_t Busy; // is transfering
|
||||
uint8_t BlockNum;
|
||||
} HAL_GDMA_OBJ, *PHAL_GDMA_OBJ;
|
||||
|
||||
void HalGdmaOpInit(IN void *Data);
|
||||
void HalGdmaOn(PHAL_GDMA_ADAPTER pHalGdmaAdapter);
|
||||
void HalGdmaOff(PHAL_GDMA_ADAPTER pHalGdmaAdapter);
|
||||
BOOL HalGdmaChInit(PHAL_GDMA_ADAPTER pHalGdmaAdapter);
|
||||
void HalGdmaChDis(PHAL_GDMA_ADAPTER pHalGdmaAdapter);
|
||||
void HalGdmaChEn(PHAL_GDMA_ADAPTER pHalGdmaAdapter);
|
||||
BOOL HalGdmaChSeting(PHAL_GDMA_ADAPTER pHalGdmaAdapter);
|
||||
BOOL HalGdmaChBlockSeting(PHAL_GDMA_ADAPTER pHalGdmaAdapter);
|
||||
void HalGdmaChIsrEn(PHAL_GDMA_ADAPTER pHalGdmaAdapter);
|
||||
void HalGdmaChIsrDis(PHAL_GDMA_ADAPTER pHalGdmaAdapter);
|
||||
uint8_t HalGdmaChIsrClean(PHAL_GDMA_ADAPTER pHalGdmaAdapter);
|
||||
void HalGdmaChCleanAutoSrc(PHAL_GDMA_ADAPTER pHalGdmaAdapter);
|
||||
void HalGdmaChCleanAutoDst(PHAL_GDMA_ADAPTER pHalGdmaAdapter);
|
||||
|
||||
extern HAL_Status HalGdmaChnlRegister (uint8_t GdmaIdx, uint8_t ChnlNum);
|
||||
extern void HalGdmaChnlUnRegister (uint8_t GdmaIdx, uint8_t ChnlNum);
|
||||
extern PHAL_GDMA_CHNL HalGdmaChnlAlloc (HAL_GDMA_CHNL *pChnlOption);
|
||||
extern void HalGdmaChnlFree (HAL_GDMA_CHNL *pChnl);
|
||||
extern BOOL HalGdmaMemCpyInit(PHAL_GDMA_OBJ pHalGdmaObj);
|
||||
extern void HalGdmaMemCpyDeInit(PHAL_GDMA_OBJ pHalGdmaObj);
|
||||
extern void* HalGdmaMemCpy(PHAL_GDMA_OBJ pHalGdmaObj, void* pDest, void* pSrc, uint32_t len);
|
||||
extern void HalGdmaMemAggr(PHAL_GDMA_OBJ pHalGdmaObj, PHAL_GDMA_BLOCK pHalGdmaBlock);
|
||||
extern BOOL HalGdmaMemCpyAggrInit(PHAL_GDMA_OBJ pHalGdmaObj);
|
||||
|
||||
extern const HAL_GDMA_OP _HalGdmaOp;
|
||||
extern const HAL_GDMA_CHNL GDMA_Chnl_Option[];
|
||||
extern const HAL_GDMA_CHNL GDMA_Multi_Block_Chnl_Option[];
|
||||
extern const uint16_t HalGdmaChnlEn[6];
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,212 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#include "rtl8195a.h"
|
||||
|
||||
#ifdef CONFIG_GPIO_EN
|
||||
|
||||
HAL_GPIO_ADAPTER gHAL_Gpio_Adapter;
|
||||
extern PHAL_GPIO_ADAPTER _pHAL_Gpio_Adapter;
|
||||
|
||||
extern void GPIO_PullCtrl_8195a(uint32_t chip_pin, uint8_t pull_type);
|
||||
|
||||
/**
|
||||
* @brief To get the GPIO IP Pin name for the given chip pin name
|
||||
*
|
||||
* @param chip_pin: The chip pin name.
|
||||
*
|
||||
* @retval The gotten GPIO IP pin name
|
||||
*/
|
||||
uint32_t
|
||||
HAL_GPIO_GetPinName(
|
||||
uint32_t chip_pin
|
||||
)
|
||||
{
|
||||
return HAL_GPIO_GetIPPinName_8195a((uint32_t)chip_pin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the GPIO pad Pull type
|
||||
*
|
||||
* @param pin: The pin for pull type control.
|
||||
* @param mode: the pull type for the pin.
|
||||
* @return None
|
||||
*/
|
||||
void
|
||||
HAL_GPIO_PullCtrl(
|
||||
uint32_t pin,
|
||||
uint32_t mode
|
||||
)
|
||||
{
|
||||
uint8_t pull_type;
|
||||
|
||||
switch (mode) {
|
||||
case hal_PullNone:
|
||||
pull_type = DIN_PULL_NONE;
|
||||
break;
|
||||
|
||||
case hal_PullDown:
|
||||
pull_type = DIN_PULL_LOW;
|
||||
break;
|
||||
|
||||
case hal_PullUp:
|
||||
pull_type = DIN_PULL_HIGH;
|
||||
break;
|
||||
|
||||
case hal_OpenDrain:
|
||||
default:
|
||||
pull_type = DIN_PULL_NONE;
|
||||
break;
|
||||
}
|
||||
|
||||
// HAL_GPIO_PullCtrl_8195a (pin, pull_type);
|
||||
GPIO_PullCtrl_8195a (pin, pull_type);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initializes a GPIO Pin by the GPIO_Pin parameters.
|
||||
*
|
||||
* @param GPIO_Pin: The data structer which contains the parameters for the GPIO Pin initialization.
|
||||
*
|
||||
* @retval HAL_Status
|
||||
*/
|
||||
void
|
||||
HAL_GPIO_Init(
|
||||
HAL_GPIO_PIN *GPIO_Pin
|
||||
)
|
||||
{
|
||||
uint8_t port_num;
|
||||
uint8_t pin_num;
|
||||
uint32_t chip_pin;
|
||||
|
||||
|
||||
if (_pHAL_Gpio_Adapter == NULL) {
|
||||
_pHAL_Gpio_Adapter = &gHAL_Gpio_Adapter;
|
||||
// DBG_GPIO_INFO("HAL_GPIO_Init: Initial GPIO Adapter\n ");
|
||||
}
|
||||
|
||||
port_num = HAL_GPIO_GET_PORT_BY_NAME(GPIO_Pin->pin_name);
|
||||
pin_num = HAL_GPIO_GET_PIN_BY_NAME(GPIO_Pin->pin_name);
|
||||
chip_pin = GPIO_GetChipPinName_8195a(port_num, pin_num);
|
||||
#if CONFIG_DEBUG_LOG > 3
|
||||
if (GpioFunctionChk(chip_pin, ENABLE) == _FALSE) {
|
||||
// if((chip_pin > 0x03) && (chip_pin != 0x25)) {
|
||||
DBG_GPIO_ERR("HAL_GPIO_Init: GPIO Pin(%x) Unavailable\n ", chip_pin);
|
||||
return;
|
||||
// }
|
||||
// else DBG_GPIO_WARN("HAL_GPIO_Init: GPIO Pin(%x) Warning for RTL8710AF!\n ", chip_pin);
|
||||
}
|
||||
#endif
|
||||
// Make the pin pull control default as High-Z
|
||||
GPIO_PullCtrl_8195a(chip_pin, HAL_GPIO_HIGHZ);
|
||||
|
||||
// HAL_Status ret =
|
||||
#if CONFIG_DEBUG_LOG > 3
|
||||
HAL_Status ret = HAL_GPIO_Init_8195a(GPIO_Pin);
|
||||
if (ret != HAL_OK) {
|
||||
GpioFunctionChk(chip_pin, DISABLE);
|
||||
}
|
||||
#else
|
||||
HAL_GPIO_Init_8195a(GPIO_Pin);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initializes a GPIO Pin as a interrupt signal
|
||||
*
|
||||
* @param GPIO_Pin: The data structer which contains the parameters for the GPIO Pin initialization.
|
||||
*
|
||||
* @retval HAL_Status
|
||||
*/
|
||||
void
|
||||
HAL_GPIO_Irq_Init(
|
||||
HAL_GPIO_PIN *GPIO_Pin
|
||||
)
|
||||
{
|
||||
if (_pHAL_Gpio_Adapter == NULL) {
|
||||
_pHAL_Gpio_Adapter = &gHAL_Gpio_Adapter;
|
||||
// DBG_GPIO_INFO("%s: Initial GPIO Adapter\n ", __FUNCTION__);
|
||||
}
|
||||
|
||||
if (_pHAL_Gpio_Adapter->IrqHandle.IrqFun == NULL) {
|
||||
_pHAL_Gpio_Adapter->IrqHandle.IrqFun = (IRQ_FUN)HAL_GPIO_MbedIrqHandler_8195a;
|
||||
_pHAL_Gpio_Adapter->IrqHandle.Priority = 6;
|
||||
HAL_GPIO_RegIrq_8195a(&_pHAL_Gpio_Adapter->IrqHandle);
|
||||
InterruptEn(&_pHAL_Gpio_Adapter->IrqHandle);
|
||||
// DBG_GPIO_INFO("%s: Initial GPIO IRQ Adapter\n ", __FUNCTION__);
|
||||
}
|
||||
|
||||
#if CONFIG_DEBUG_LOG > 3
|
||||
uint8_t port_num = HAL_GPIO_GET_PORT_BY_NAME(GPIO_Pin->pin_name);
|
||||
uint8_t pin_num = HAL_GPIO_GET_PIN_BY_NAME(GPIO_Pin->pin_name);
|
||||
uint32_t chip_pin = GPIO_GetChipPinName_8195a(port_num, pin_num);
|
||||
if (GpioFunctionChk(chip_pin, ENABLE) == _FALSE) {
|
||||
DBG_GPIO_ERR("HAL_GPIO_Irq_Init: GPIO Pin(%x) Unavailable\n ", chip_pin);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
DBG_GPIO_INFO("HAL_GPIO_Irq_Init: GPIO(name=0x%x)(mode=%d)\n ", GPIO_Pin->pin_name,
|
||||
GPIO_Pin->pin_mode);
|
||||
HAL_GPIO_MaskIrq_8195a(GPIO_Pin);
|
||||
// HAL_Status ret =
|
||||
|
||||
#if CONFIG_DEBUG_LOG > 3
|
||||
HAL_Status ret = HAL_GPIO_Init_8195a(GPIO_Pin);
|
||||
if (ret != HAL_OK) {
|
||||
GpioFunctionChk(chip_pin, DISABLE);
|
||||
}
|
||||
#else
|
||||
HAL_GPIO_Init_8195a(GPIO_Pin);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief UnInitial GPIO Adapter
|
||||
*
|
||||
*
|
||||
* @retval HAL_Status
|
||||
*/
|
||||
void
|
||||
HAL_GPIO_IP_DeInit(
|
||||
void
|
||||
)
|
||||
{
|
||||
if (_pHAL_Gpio_Adapter != NULL) {
|
||||
InterruptDis(&_pHAL_Gpio_Adapter->IrqHandle);
|
||||
HAL_GPIO_UnRegIrq_8195a(&_pHAL_Gpio_Adapter->IrqHandle);
|
||||
_pHAL_Gpio_Adapter = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief De-Initializes a GPIO Pin, reset it as default setting.
|
||||
*
|
||||
* @param GPIO_Pin: The data structer which contains the parameters for the GPIO Pin.
|
||||
*
|
||||
* @retval HAL_Status
|
||||
*/
|
||||
void
|
||||
HAL_GPIO_DeInit(
|
||||
HAL_GPIO_PIN *GPIO_Pin
|
||||
)
|
||||
{
|
||||
#if CONFIG_DEBUG_LOG > 3
|
||||
uint8_t port_num = HAL_GPIO_GET_PORT_BY_NAME(GPIO_Pin->pin_name);
|
||||
uint8_t pin_num = HAL_GPIO_GET_PIN_BY_NAME(GPIO_Pin->pin_name);
|
||||
#endif
|
||||
HAL_GPIO_DeInit_8195a(GPIO_Pin);
|
||||
#if CONFIG_DEBUG_LOG > 3
|
||||
GpioFunctionChk(GPIO_GetChipPinName_8195a(port_num, pin_num), DISABLE);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#endif // CONFIG_GPIO_EN
|
||||
|
|
@ -0,0 +1,250 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _HAL_GPIO_H_
|
||||
#define _HAL_GPIO_H_
|
||||
|
||||
#define HAL_GPIO_PIN_INT_MODE 0x80
|
||||
|
||||
typedef enum {
|
||||
_PORT_A = 0,
|
||||
_PORT_B = 1,
|
||||
_PORT_C = 2,
|
||||
_PORT_D = 3,
|
||||
_PORT_E = 4,
|
||||
_PORT_F = 5,
|
||||
_PORT_G = 6,
|
||||
_PORT_H = 7,
|
||||
_PORT_I = 8,
|
||||
_PORT_J = 9,
|
||||
_PORT_K = 10,
|
||||
|
||||
_PORT_MAX
|
||||
} HAL_GPIO_PORT_NAME;
|
||||
|
||||
typedef enum {
|
||||
_PA_0 = (_PORT_A<<4|0),
|
||||
_PA_1 = (_PORT_A<<4|1),
|
||||
_PA_2 = (_PORT_A<<4|2),
|
||||
_PA_3 = (_PORT_A<<4|3),
|
||||
_PA_4 = (_PORT_A<<4|4),
|
||||
_PA_5 = (_PORT_A<<4|5),
|
||||
_PA_6 = (_PORT_A<<4|6),
|
||||
_PA_7 = (_PORT_A<<4|7),
|
||||
|
||||
_PB_0 = (_PORT_B<<4|0),
|
||||
_PB_1 = (_PORT_B<<4|1),
|
||||
_PB_2 = (_PORT_B<<4|2),
|
||||
_PB_3 = (_PORT_B<<4|3),
|
||||
_PB_4 = (_PORT_B<<4|4),
|
||||
_PB_5 = (_PORT_B<<4|5),
|
||||
_PB_6 = (_PORT_B<<4|6),
|
||||
_PB_7 = (_PORT_B<<4|7),
|
||||
|
||||
_PC_0 = (_PORT_C<<4|0),
|
||||
_PC_1 = (_PORT_C<<4|1),
|
||||
_PC_2 = (_PORT_C<<4|2),
|
||||
_PC_3 = (_PORT_C<<4|3),
|
||||
_PC_4 = (_PORT_C<<4|4),
|
||||
_PC_5 = (_PORT_C<<4|5),
|
||||
_PC_6 = (_PORT_C<<4|6),
|
||||
_PC_7 = (_PORT_C<<4|7),
|
||||
_PC_8 = (_PORT_C<<4|8),
|
||||
_PC_9 = (_PORT_C<<4|9),
|
||||
|
||||
_PD_0 = (_PORT_D<<4|0),
|
||||
_PD_1 = (_PORT_D<<4|1),
|
||||
_PD_2 = (_PORT_D<<4|2),
|
||||
_PD_3 = (_PORT_D<<4|3),
|
||||
_PD_4 = (_PORT_D<<4|4),
|
||||
_PD_5 = (_PORT_D<<4|5),
|
||||
_PD_6 = (_PORT_D<<4|6),
|
||||
_PD_7 = (_PORT_D<<4|7),
|
||||
_PD_8 = (_PORT_D<<4|8),
|
||||
_PD_9 = (_PORT_D<<4|9),
|
||||
|
||||
_PE_0 = (_PORT_E<<4|0),
|
||||
_PE_1 = (_PORT_E<<4|1),
|
||||
_PE_2 = (_PORT_E<<4|2),
|
||||
_PE_3 = (_PORT_E<<4|3),
|
||||
_PE_4 = (_PORT_E<<4|4),
|
||||
_PE_5 = (_PORT_E<<4|5),
|
||||
_PE_6 = (_PORT_E<<4|6),
|
||||
_PE_7 = (_PORT_E<<4|7),
|
||||
_PE_8 = (_PORT_E<<4|8),
|
||||
_PE_9 = (_PORT_E<<4|9),
|
||||
_PE_A = (_PORT_E<<4|10),
|
||||
|
||||
_PF_0 = (_PORT_F<<4|0),
|
||||
_PF_1 = (_PORT_F<<4|1),
|
||||
_PF_2 = (_PORT_F<<4|2),
|
||||
_PF_3 = (_PORT_F<<4|3),
|
||||
_PF_4 = (_PORT_F<<4|4),
|
||||
_PF_5 = (_PORT_F<<4|5),
|
||||
// _PF_6 = (_PORT_F<<4|6),
|
||||
// _PF_7 = (_PORT_F<<4|7),
|
||||
|
||||
_PG_0 = (_PORT_G<<4|0),
|
||||
_PG_1 = (_PORT_G<<4|1),
|
||||
_PG_2 = (_PORT_G<<4|2),
|
||||
_PG_3 = (_PORT_G<<4|3),
|
||||
_PG_4 = (_PORT_G<<4|4),
|
||||
_PG_5 = (_PORT_G<<4|5),
|
||||
_PG_6 = (_PORT_G<<4|6),
|
||||
_PG_7 = (_PORT_G<<4|7),
|
||||
|
||||
_PH_0 = (_PORT_H<<4|0),
|
||||
_PH_1 = (_PORT_H<<4|1),
|
||||
_PH_2 = (_PORT_H<<4|2),
|
||||
_PH_3 = (_PORT_H<<4|3),
|
||||
_PH_4 = (_PORT_H<<4|4),
|
||||
_PH_5 = (_PORT_H<<4|5),
|
||||
_PH_6 = (_PORT_H<<4|6),
|
||||
_PH_7 = (_PORT_H<<4|7),
|
||||
|
||||
_PI_0 = (_PORT_I<<4|0),
|
||||
_PI_1 = (_PORT_I<<4|1),
|
||||
_PI_2 = (_PORT_I<<4|2),
|
||||
_PI_3 = (_PORT_I<<4|3),
|
||||
_PI_4 = (_PORT_I<<4|4),
|
||||
_PI_5 = (_PORT_I<<4|5),
|
||||
_PI_6 = (_PORT_I<<4|6),
|
||||
_PI_7 = (_PORT_I<<4|7),
|
||||
|
||||
_PJ_0 = (_PORT_J<<4|0),
|
||||
_PJ_1 = (_PORT_J<<4|1),
|
||||
_PJ_2 = (_PORT_J<<4|2),
|
||||
_PJ_3 = (_PORT_J<<4|3),
|
||||
_PJ_4 = (_PORT_J<<4|4),
|
||||
_PJ_5 = (_PORT_J<<4|5),
|
||||
_PJ_6 = (_PORT_J<<4|6),
|
||||
// _PJ_7 = (_PORT_J<<4|7),
|
||||
|
||||
_PK_0 = (_PORT_K<<4|0),
|
||||
_PK_1 = (_PORT_K<<4|1),
|
||||
_PK_2 = (_PORT_K<<4|2),
|
||||
_PK_3 = (_PORT_K<<4|3),
|
||||
_PK_4 = (_PORT_K<<4|4),
|
||||
_PK_5 = (_PORT_K<<4|5),
|
||||
_PK_6 = (_PORT_K<<4|6),
|
||||
// _PK_7 = (_PORT_K<<4|7),
|
||||
|
||||
// Not connected
|
||||
_PIN_NC = (int)0xFFFFFFFF
|
||||
} HAL_PIN_NAME;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GPIO_PIN_LOW = 0,
|
||||
GPIO_PIN_HIGH = 1,
|
||||
GPIO_PIN_ERR = 2 // read Pin error
|
||||
} HAL_GPIO_PIN_STATE;
|
||||
|
||||
typedef enum {
|
||||
DIN_PULL_NONE = 0, //floating or high impedance ?
|
||||
DIN_PULL_LOW = 1,
|
||||
DIN_PULL_HIGH = 2,
|
||||
|
||||
DOUT_PUSH_PULL = 3,
|
||||
DOUT_OPEN_DRAIN = 4,
|
||||
|
||||
INT_LOW = (5|HAL_GPIO_PIN_INT_MODE), // Interrupt Low level trigger
|
||||
INT_HIGH = (6|HAL_GPIO_PIN_INT_MODE), // Interrupt High level trigger
|
||||
INT_FALLING = (7|HAL_GPIO_PIN_INT_MODE), // Interrupt Falling edge trigger
|
||||
INT_RISING = (8|HAL_GPIO_PIN_INT_MODE) // Interrupt Rising edge trigger
|
||||
} HAL_GPIO_PIN_MODE;
|
||||
|
||||
enum {
|
||||
GPIO_PORT_A = 0,
|
||||
GPIO_PORT_B = 1,
|
||||
GPIO_PORT_C = 2,
|
||||
GPIO_PORT_D = 3
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
hal_PullNone = 0,
|
||||
hal_PullUp = 1,
|
||||
hal_PullDown = 2,
|
||||
hal_OpenDrain = 3,
|
||||
hal_PullDefault = hal_PullNone
|
||||
} HAL_PinMode;
|
||||
|
||||
typedef struct _HAL_GPIO_PORT_ {
|
||||
uint32_t out_data; // to write the GPIO port
|
||||
uint32_t in_data; // to read the GPIO port
|
||||
uint32_t dir; // config each pin direction
|
||||
}HAL_GPIO_PORT, *PHAL_GPIO_PORT;
|
||||
|
||||
#define HAL_GPIO_PIN_NAME(port,pin) (((port)<<5)|(pin))
|
||||
#define HAL_GPIO_GET_PORT_BY_NAME(x) ((x>>5) & 0x03)
|
||||
#define HAL_GPIO_GET_PIN_BY_NAME(x) (x & 0x1f)
|
||||
|
||||
typedef struct _HAL_GPIO_PIN_ {
|
||||
HAL_GPIO_PIN_MODE pin_mode;
|
||||
uint32_t pin_name; // Pin: [7:5]: port number, [4:0]: pin number
|
||||
}HAL_GPIO_PIN, *PHAL_GPIO_PIN;
|
||||
|
||||
#if defined(__ICCARM__)
|
||||
typedef struct _HAL_GPIO_OP_ {
|
||||
void* dummy;
|
||||
}HAL_GPIO_OP, *PHAL_GPIO_OP;
|
||||
#endif
|
||||
|
||||
typedef void (*GPIO_IRQ_FUN)(void *Data, uint32_t Id);
|
||||
typedef void (*GPIO_USER_IRQ_FUN)(uint32_t Id);
|
||||
|
||||
typedef struct _HAL_GPIO_ADAPTER_ {
|
||||
IRQ_HANDLE IrqHandle; // GPIO HAL IRQ Handle
|
||||
GPIO_USER_IRQ_FUN UserIrqHandler; // GPIO IRQ Handler
|
||||
GPIO_IRQ_FUN PortA_IrqHandler[32]; // The interrupt handler triggered by Port A[x]
|
||||
void *PortA_IrqData[32];
|
||||
void (*EnterCritical)(void);
|
||||
void (*ExitCritical)(void);
|
||||
uint32_t Local_Gpio_Dir[3]; // to record direction setting: 0- IN, 1- Out
|
||||
uint8_t Gpio_Func_En; // Is GPIO HW function enabled ?
|
||||
uint8_t Locked;
|
||||
}HAL_GPIO_ADAPTER, *PHAL_GPIO_ADAPTER;
|
||||
|
||||
uint32_t
|
||||
HAL_GPIO_GetPinName(
|
||||
uint32_t chip_pin
|
||||
);
|
||||
|
||||
void
|
||||
HAL_GPIO_PullCtrl(
|
||||
uint32_t pin,
|
||||
uint32_t mode
|
||||
);
|
||||
|
||||
void
|
||||
HAL_GPIO_Init(
|
||||
HAL_GPIO_PIN *GPIO_Pin
|
||||
);
|
||||
|
||||
void
|
||||
HAL_GPIO_DeInit(
|
||||
HAL_GPIO_PIN *GPIO_Pin
|
||||
);
|
||||
|
||||
void
|
||||
HAL_GPIO_Irq_Init(
|
||||
HAL_GPIO_PIN *GPIO_Pin
|
||||
);
|
||||
|
||||
void
|
||||
HAL_GPIO_IP_DeInit(
|
||||
void
|
||||
);
|
||||
|
||||
|
||||
|
||||
extern uint16_t GPIOState[_PORT_MAX]; // побитно 16 бит для каждого порта (A..K), бит=номер задействованного пина в порту на периферию.
|
||||
|
||||
#endif // end of "#define _HAL_GPIO_H_"
|
||||
|
||||
2941
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_i2c.c
Normal file
2941
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_i2c.c
Normal file
File diff suppressed because it is too large
Load diff
594
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_i2c.h
Normal file
594
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_i2c.h
Normal file
|
|
@ -0,0 +1,594 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _HAL_I2C_H_ //#ifndef _HAL_I2C_H_
|
||||
#define _HAL_I2C_H_
|
||||
|
||||
#include "rtl8195a_i2c.h"
|
||||
#include "hal_gdma.h"
|
||||
|
||||
//================= I2C CONFIGURATION START ==================
|
||||
// I2C SAL User Configuration Flags
|
||||
|
||||
// I2C SAL operation types
|
||||
#define I2C_POLL_OP_TYPE 1 //1
|
||||
#define I2C_INTR_OP_TYPE 1 //1
|
||||
#define I2C_DMA_OP_TYPE 1 //1
|
||||
|
||||
// I2C supports user register address
|
||||
#define I2C_USER_REG_ADDR 1 //I2C User specific register address by using
|
||||
//the first I2C data as the register
|
||||
//address
|
||||
|
||||
// I2C SAL used module. Please set the I2C module flag to 1 to enable the related
|
||||
// I2C module functions.
|
||||
#define I2C0_USED 1
|
||||
#define I2C1_USED 1
|
||||
#define I2C2_USED 1
|
||||
#define I2C3_USED 1
|
||||
//================= I2C CONFIGURATION END ===================
|
||||
|
||||
|
||||
//================= I2C HAL START ==========================
|
||||
// I2C debug output
|
||||
#define I2C_PREFIX "RTL8195A[i2c]: "
|
||||
#define I2C_PREFIX_LVL " [i2c_DBG]: "
|
||||
|
||||
typedef enum _I2C_DBG_LVL_ {
|
||||
HAL_I2C_LVL = 0x01,
|
||||
SAL_I2C_LVL = 0x02,
|
||||
VERI_I2C_LVL = 0x03,
|
||||
}I2C_DBG_LVL,*PI2C_DBG_LVL;
|
||||
|
||||
#if CONFIG_DEBUG_LOG > 0
|
||||
#ifdef CONFIG_DEBUG_LOG_I2C_HAL
|
||||
#define DBG_I2C_LOG_PERD 100
|
||||
|
||||
#define I2CDBGLVL 0xFF
|
||||
#define DBG_8195A_I2C(...) do{ \
|
||||
_DbgDump(I2C_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define DBG_8195A_I2C_LVL(LVL,...) do{\
|
||||
if (LVL&I2CDBGLVL){\
|
||||
_DbgDump(I2C_PREFIX_LVL __VA_ARGS__);\
|
||||
}\
|
||||
}while(0)
|
||||
#else
|
||||
#define DBG_I2C_LOG_PERD 100
|
||||
#define DBG_8195A_I2C(...)
|
||||
#define DBG_8195A_I2C_LVL(...)
|
||||
#endif
|
||||
#else
|
||||
#define DBG_I2C_LOG_PERD 100
|
||||
#define DBG_8195A_I2C(...)
|
||||
#define DBG_8195A_I2C_LVL(...)
|
||||
#endif
|
||||
|
||||
#define I2C_MTR_RTY_CNT 1024
|
||||
//======================================================
|
||||
// I2C HAL related enumeration
|
||||
// I2C Module Selection
|
||||
typedef enum _I2C_MODULE_SEL_ {
|
||||
I2C0_SEL = 0x0,
|
||||
I2C1_SEL = 0x1,
|
||||
I2C2_SEL = 0x2,
|
||||
I2C3_SEL = 0x3,
|
||||
}I2C_MODULE_SEL,*PI2C_MODULE_SEL;
|
||||
|
||||
// I2C HAL initial data structure
|
||||
typedef struct _HAL_I2C_INIT_DAT_ {
|
||||
uint8_t I2CIdx; //I2C index used
|
||||
uint8_t I2CEn; //I2C module enable
|
||||
uint8_t I2CMaster; //Master or Slave mode
|
||||
uint8_t I2CAddrMod; //I2C addressing mode(7-bit, 10-bit)
|
||||
|
||||
uint8_t I2CSpdMod; //I2C speed mode(Standard, Fast, High)
|
||||
uint8_t I2CSetup; //I2C SDA setup time
|
||||
uint8_t I2CRXTL; //I2C RX FIFO Threshold
|
||||
uint8_t I2CTXTL; //I2C TX FIFO Threshold
|
||||
|
||||
uint8_t I2CBusLd; //I2C bus load (pf) for high speed mode
|
||||
uint8_t I2CReSTR; //I2C restart support
|
||||
uint8_t I2CGC; //I2C general support
|
||||
uint8_t I2CStartB; //I2C start byte support
|
||||
|
||||
uint8_t I2CSlvNoAck; //I2C slave no ack support
|
||||
uint8_t I2CDMACtrl; //I2C DMA feature support
|
||||
uint8_t I2CCmd; //I2C Command
|
||||
uint8_t I2CDataLen; //I2C Data Length
|
||||
|
||||
uint8_t I2CSlvAckGC; //I2C slave acks to General Call
|
||||
uint8_t I2CStop; //I2C issues STOP bit or not
|
||||
uint16_t RSVD0; //Bit0: used to control HalI2CMassSendRtl8195a_Patch sending
|
||||
// RESTART or not by upper layer SW.
|
||||
|
||||
uint8_t *I2CRWData; //I2C Read/Write data pointer
|
||||
|
||||
uint16_t I2CIntrMSK; //I2C Interrupt Mask
|
||||
uint16_t I2CIntrClr; //I2C Interrupt register to clear
|
||||
|
||||
uint16_t I2CAckAddr; //I2C target address in I2C Master mode,
|
||||
//ack address in I2C Slave mode
|
||||
uint16_t I2CSdaHd; //I2C SDA hold time
|
||||
|
||||
uint32_t I2CClk; //I2C bus clock (in kHz)
|
||||
|
||||
uint8_t I2CTxDMARqLv; //I2C TX DMA Empty Level
|
||||
uint8_t I2CRxDMARqLv; //I2C RX DMA Full Level
|
||||
uint16_t RSVD1; //Reserved
|
||||
}HAL_I2C_INIT_DAT,*PHAL_I2C_INIT_DAT;
|
||||
|
||||
// I2C HAL Operations
|
||||
typedef struct _HAL_I2C_OP_ {
|
||||
HAL_Status (*HalI2CInit) (void *Data); //HAL I2C initialization
|
||||
HAL_Status (*HalI2CDeInit) (void *Data); //HAL I2C de-initialization
|
||||
HAL_Status (*HalI2CSend) (void *Data); //HAL I2C send
|
||||
uint8_t (*HalI2CReceive) (void *Data); //HAL I2C receive
|
||||
HAL_Status (*HalI2CEnable) (void *Data); //HAL I2C enable module
|
||||
HAL_Status (*HalI2CIntrCtrl) (void *Data); //HAL I2C interrupt control
|
||||
uint32_t (*HalI2CReadReg) (void *Data, uint8_t I2CReg);//HAL I2C read register
|
||||
HAL_Status (*HalI2CWriteReg) (void *Data, uint8_t I2CReg, uint32_t RegVal);//HAL I2C write register
|
||||
HAL_Status (*HalI2CSetCLK) (void *Data); //HAL I2C set bus clock
|
||||
HAL_Status (*HalI2CMassSend) (void *Data); //HAL I2C mass send
|
||||
HAL_Status (*HalI2CClrIntr) (void *Data); //HAL I2C clear interrupts
|
||||
HAL_Status (*HalI2CClrAllIntr) (void *Data); //HAL I2C clear all interrupts
|
||||
HAL_Status (*HalI2CDMACtrl) (void *Data); //HAL I2C DMA control
|
||||
}HAL_I2C_OP, *PHAL_I2C_OP;
|
||||
//================= I2C HAL END ===========================
|
||||
|
||||
|
||||
//================= I2C SAL START ==========================
|
||||
//I2C SAL Macros
|
||||
|
||||
//======================================================
|
||||
// I2C SAL related enumerations
|
||||
// I2C Extend Features
|
||||
typedef enum _I2C_EXD_SUPPORT_{
|
||||
I2C_EXD_RESTART = 0x1, //BIT_0, RESTART bit
|
||||
I2C_EXD_GENCALL = 0x2, //BIT_1, Master generates General Call. All "send" operations generate General Call addresss
|
||||
I2C_EXD_STARTB = 0x4, //BIT_2, Using START BYTE, instead of START Bit
|
||||
I2C_EXD_SLVNOACK = 0x8, //BIT_3, Slave no ack to master
|
||||
I2C_EXD_BUS400PF = 0x10, //BIT_4, I2C bus loading is 400pf
|
||||
I2C_EXD_SLVACKGC = 0x20, //BIT_5, Slave acks to a General Call
|
||||
I2C_EXD_USER_REG = 0x40, //BIT_6, Using User Register Address
|
||||
I2C_EXD_USER_TWOB = 0x80, //BIT_7, User Register Address is 2-byte
|
||||
I2C_EXD_MTR_ADDR_RTY= 0x100, //BIT_8, Master retries to send start condition and Slave address when the slave doesn't ack
|
||||
// the address.
|
||||
I2C_EXD_MTR_ADDR_UPD= 0x200, //BIT_9, Master dynamically updates slave address
|
||||
I2C_EXD_MTR_HOLD_BUS= 0x400, //BIT_10, Master doesn't generate STOP when the FIFO is empty. This would make Master hold
|
||||
// the bus.
|
||||
}I2C_EXD_SUPPORT,*PI2C_EXD_SUPPORT;
|
||||
|
||||
// I2C operation type
|
||||
typedef enum _I2C_OP_TYPE_ {
|
||||
I2C_POLL_TYPE = 0x0,
|
||||
I2C_DMA_TYPE = 0x1,
|
||||
I2C_INTR_TYPE = 0x2,
|
||||
}I2C_OP_TYPE, *PI2C_OP_TYPE;
|
||||
|
||||
// I2C pinmux selection
|
||||
typedef enum _I2C_PINMUX_ {
|
||||
I2C_PIN_S0 = 0x0,
|
||||
I2C_PIN_S1 = 0x1,
|
||||
I2C_PIN_S2 = 0x2,
|
||||
I2C_PIN_S3 = 0x3, //Only valid for I2C0 and I2C3
|
||||
}I2C_PINMUX, *PI2C_PINMUX;
|
||||
|
||||
// I2C module status
|
||||
typedef enum _I2C_MODULE_STATUS_ {
|
||||
I2C_DISABLE = 0x0,
|
||||
I2C_ENABLE = 0x1,
|
||||
}I2C_MODULE_STATUS, *PI2C_MODULE_STATUS;
|
||||
|
||||
// I2C device status
|
||||
typedef enum _I2C_Device_STATUS_ {
|
||||
I2C_STS_UNINITIAL = 0x00,
|
||||
I2C_STS_INITIALIZED = 0x01,
|
||||
I2C_STS_IDLE = 0x02,
|
||||
|
||||
I2C_STS_TX_READY = 0x03,
|
||||
I2C_STS_TX_ING = 0x04,
|
||||
|
||||
I2C_STS_RX_READY = 0x05,
|
||||
I2C_STS_RX_ING = 0x06,
|
||||
|
||||
I2C_STS_ERROR = 0x10,
|
||||
I2C_STS_TIMEOUT = 0x11,
|
||||
}I2C_Device_STATUS, *PI2C_Device_STATUS;
|
||||
|
||||
// I2C feature status
|
||||
typedef enum _I2C_FEATURE_STATUS_{
|
||||
I2C_FEATURE_DISABLED = 0,
|
||||
I2C_FEATURE_ENABLED = 1,
|
||||
}I2C_FEATURE_STATUS,*PI2C_FEATURE_STATUS;
|
||||
|
||||
// I2C device mode
|
||||
typedef enum _I2C_DEV_MODE_ {
|
||||
I2C_SLAVE_MODE = 0x0,
|
||||
I2C_MASTER_MODE = 0x1,
|
||||
}I2C_DEV_MODE, *PI2C_DEV_MODE;
|
||||
|
||||
// I2C Bus Transmit/Receive
|
||||
typedef enum _I2C_DIRECTION_ {
|
||||
I2C_ONLY_TX = 0x1,
|
||||
I2C_ONLY_RX = 0x2,
|
||||
I2C_TXRX = 0x3,
|
||||
}I2C_DIRECTION, *PI2C_DIRECTION;
|
||||
|
||||
//I2C DMA module number
|
||||
typedef enum _I2C_DMA_MODULE_SEL_ {
|
||||
I2C_DMA_MODULE_0 = 0x0,
|
||||
I2C_DMA_MODULE_1 = 0x1
|
||||
}I2C_DMA_MODULE_SEL, *PI2C_DMA_MODULE_SEL;
|
||||
|
||||
// I2C0 DMA peripheral number
|
||||
typedef enum _I2C0_DMA_PERI_NUM_ {
|
||||
I2C0_DMA_TX_NUM = 0x8,
|
||||
I2C0_DMA_RX_NUM = 0x9,
|
||||
}I2C0_DMA_PERI_NUM,*PI2C0_DMA_PERI_NUM;
|
||||
|
||||
// I2C1 DMA peripheral number
|
||||
typedef enum _I2C1_DMA_PERI_NUM_ {
|
||||
I2C1_DMA_TX_NUM = 0xA,
|
||||
I2C1_DMA_RX_NUM = 0xB,
|
||||
}I2C1_DMA_PERI_NUM,*PI2C1_DMA_PERI_NUM;
|
||||
|
||||
// I2C0 DMA module used
|
||||
typedef enum _I2C0_DMA_MODULE_ {
|
||||
I2C0_DMA0 = 0x0,
|
||||
I2C0_DMA1 = 0x1,
|
||||
}I2C0_DMA_MODULE,*PI2C0_DMA_MODULE;
|
||||
|
||||
// I2C0 DMA module used
|
||||
typedef enum _I2C1_DMA_MODULE_ {
|
||||
I2C1_DMA0 = 0x0,
|
||||
I2C1_DMA1 = 0x1,
|
||||
}I2C1_DMA_MODULE,*PI2C1_DMA_MODULE;
|
||||
|
||||
// I2C command type
|
||||
typedef enum _I2C_COMMAND_TYPE_ {
|
||||
I2C_WRITE_CMD = 0x0,
|
||||
I2C_READ_CMD = 0x1,
|
||||
}I2C_COMMAND_TYPE,*PI2C_COMMAND_TYPE;
|
||||
|
||||
// I2C STOP BIT
|
||||
typedef enum _I2C_STOP_TYPE_ {
|
||||
I2C_STOP_DIS = 0x0,
|
||||
I2C_STOP_EN = 0x1,
|
||||
}I2C_STOP_TYPE, *PI2C_STOP_TYPE;
|
||||
|
||||
// I2C error type
|
||||
typedef enum _I2C_ERR_TYPE_ {
|
||||
I2C_ERR_RX_UNDER = 0x01, //I2C RX FIFO Underflow
|
||||
I2C_ERR_RX_OVER = 0x02, //I2C RX FIFO Overflow
|
||||
I2C_ERR_TX_OVER = 0x04, //I2C TX FIFO Overflow
|
||||
I2C_ERR_TX_ABRT = 0x08, //I2C TX terminated
|
||||
I2C_ERR_SLV_TX_NACK = 0x10, //I2C slave transmission terminated by master NACK,
|
||||
//but there are data in slave TX FIFO
|
||||
I2C_ERR_MST_A_NACK = 0x12,
|
||||
I2C_ERR_MST_D_NACK = 0x13,
|
||||
I2C_ERR_USER_REG_TO = 0x20,
|
||||
|
||||
I2C_ERR_RX_CMD_TO = 0x21,
|
||||
I2C_ERR_RX_FF_TO = 0x22,
|
||||
I2C_ERR_TX_CMD_TO = 0x23,
|
||||
I2C_ERR_TX_FF_TO = 0x24,
|
||||
|
||||
I2C_ERR_TX_ADD_TO = 0x25,
|
||||
I2C_ERR_RX_ADD_TO = 0x26,
|
||||
}I2C_ERR_TYPE, *PI2C_ERR_TYPE;
|
||||
|
||||
// I2C Time Out type
|
||||
typedef enum _I2C_TIMEOUT_TYPE_ {
|
||||
I2C_TIMEOOUT_DISABLE = 0x00,
|
||||
I2C_TIMEOOUT_ENDLESS = -1 // 0xFFFFFFFF,
|
||||
}I2C_TIMEOUT_TYPE, *PI2C_TIMEOUT_TYPE;
|
||||
|
||||
//======================================================
|
||||
// SAL I2C related data structures
|
||||
// I2C user callback adapter
|
||||
typedef struct _SAL_I2C_USERCB_ADPT_ {
|
||||
void (*USERCB) (void *Data);
|
||||
uint32_t USERData;
|
||||
}SAL_I2C_USERCB_ADPT, *PSAL_I2C_USERCB_ADPT;
|
||||
|
||||
// I2C user callback structure
|
||||
typedef struct _SAL_I2C_USER_CB_ {
|
||||
PSAL_I2C_USERCB_ADPT pTXCB; //I2C Transmit Callback
|
||||
PSAL_I2C_USERCB_ADPT pTXCCB; //I2C Transmit Complete Callback
|
||||
PSAL_I2C_USERCB_ADPT pRXCB; //I2C Receive Callback
|
||||
PSAL_I2C_USERCB_ADPT pRXCCB; //I2C Receive Complete Callback
|
||||
PSAL_I2C_USERCB_ADPT pRDREQCB; //I2C Read Request Callback
|
||||
PSAL_I2C_USERCB_ADPT pERRCB; //I2C Error Callback
|
||||
PSAL_I2C_USERCB_ADPT pDMATXCB; //I2C DMA Transmit Callback
|
||||
PSAL_I2C_USERCB_ADPT pDMATXCCB; //I2C DMA Transmit Complete Callback
|
||||
PSAL_I2C_USERCB_ADPT pDMARXCB; //I2C DMA Receive Callback
|
||||
PSAL_I2C_USERCB_ADPT pDMARXCCB; //I2C DMA Receive Complete Callback
|
||||
PSAL_I2C_USERCB_ADPT pGENCALLCB; //I2C General Call Callback
|
||||
}SAL_I2C_USER_CB, *PSAL_I2C_USER_CB;
|
||||
|
||||
// I2C Transmit Buffer
|
||||
typedef struct _SAL_I2C_TRANSFER_BUF_ {
|
||||
uint16_t DataLen; //I2C Transmfer Length
|
||||
uint16_t TargetAddr; //I2C Target Address. It's only valid in Master Mode.
|
||||
uint32_t RegAddr; //I2C Register Address. It's only valid in Master Mode.
|
||||
uint32_t RSVD; //
|
||||
uint8_t *pDataBuf; //I2C Transfer Buffer Pointer
|
||||
}SAL_I2C_TRANSFER_BUF,*PSAL_I2C_TRANSFER_BUF;
|
||||
|
||||
typedef struct _SAL_I2C_DMA_USER_DEF_ {
|
||||
uint8_t TxDatSrcWdth;
|
||||
uint8_t TxDatDstWdth;
|
||||
uint8_t TxDatSrcBstSz;
|
||||
uint8_t TxDatDstBstSz;
|
||||
uint8_t TxChNo;
|
||||
uint8_t RSVD0;
|
||||
uint16_t RSVD1;
|
||||
uint8_t RxDatSrcWdth;
|
||||
uint8_t RxDatDstWdth;
|
||||
uint8_t RxDatSrcBstSz;
|
||||
uint8_t RxDatDstBstSz;
|
||||
uint8_t RxChNo;
|
||||
uint8_t RSVD2;
|
||||
uint16_t RSVD3;
|
||||
}SAL_I2C_DMA_USER_DEF, *PSAL_I2C_DMA_USER_DEF;
|
||||
|
||||
// RTK I2C OP
|
||||
typedef struct _RTK_I2C_OP_ {
|
||||
HAL_Status (*Init) (void *Data);
|
||||
HAL_Status (*DeInit) (void *Data);
|
||||
HAL_Status (*Send) (void *Data);
|
||||
HAL_Status (*Receive) (void *Data);
|
||||
HAL_Status (*IoCtrl) (void *Data);
|
||||
HAL_Status (*PowerCtrl) (void *Data);
|
||||
}RTK_I2C_OP, *PRTK_I2C_OP;
|
||||
|
||||
// Software API Level I2C Handler
|
||||
typedef struct _SAL_I2C_HND_ {
|
||||
uint8_t DevNum; //I2C device number
|
||||
uint8_t PinMux; //I2C pin mux seletion
|
||||
uint8_t OpType; //I2C operation type selection
|
||||
volatile uint8_t DevSts; //I2C device status
|
||||
|
||||
uint8_t I2CMaster; //I2C Master or Slave mode
|
||||
uint8_t I2CAddrMod; //I2C 7-bit or 10-bit mode
|
||||
uint8_t I2CSpdMod; //I2C SS/ FS/ HS speed mode
|
||||
uint8_t I2CAckAddr; //I2C target address in Master
|
||||
//mode or ack address in Slave
|
||||
//mode
|
||||
|
||||
uint16_t I2CClk; //I2C bus clock
|
||||
uint8_t MasterRead; //I2C Master Read Supported,
|
||||
//An Address will be sent before
|
||||
//read data back.
|
||||
|
||||
uint8_t I2CDmaSel; //I2C DMA module select
|
||||
// 0 for DMA0,
|
||||
// 1 for DMA1
|
||||
uint8_t I2CTxDMARqLv; //I2C TX DMA Empty Level
|
||||
uint8_t I2CRxDMARqLv; //I2C RX DMA Full Level
|
||||
uint16_t RSVD0; //Reserved
|
||||
|
||||
uint32_t AddRtyTimeOut; //I2C TimeOut Value for master send address retry
|
||||
//(Originally Reserved.)
|
||||
|
||||
uint32_t I2CExd; //I2C extended options:
|
||||
//bit 0: I2C RESTART supported,
|
||||
// 0 for NOT supported,
|
||||
// 1 for supported
|
||||
//bit 1: I2C General Call supported
|
||||
// 0 for NOT supported,
|
||||
// 1 for supported
|
||||
//bit 2: I2C START Byte supported
|
||||
// 0 for NOT supported,
|
||||
// 1 for supported
|
||||
//bit 3: I2C Slave-No-Ack
|
||||
// supported
|
||||
// 0 for NOT supported,
|
||||
// 1 for supported
|
||||
//bit 4: I2C bus loading,
|
||||
// 0 for 100pf,
|
||||
// 1 for 400pf
|
||||
//bit 5: I2C slave ack to General
|
||||
// Call
|
||||
//bit 6: I2C User register address
|
||||
//bit 7: I2C 2-Byte User register
|
||||
// address
|
||||
//bit 8: I2C slave address no ack retry,
|
||||
// It's only for Master mode,
|
||||
// when slave doesn't ack the
|
||||
// address
|
||||
//bit 31~bit 8: Reserved
|
||||
uint32_t ErrType; //
|
||||
uint32_t TimeOut; //I2C IO Timeout count, in ms
|
||||
|
||||
PHAL_I2C_INIT_DAT pInitDat; //Pointer to I2C initial data struct
|
||||
PSAL_I2C_TRANSFER_BUF pTXBuf; //Pointer to I2C TX buffer
|
||||
PSAL_I2C_TRANSFER_BUF pRXBuf; //Pointer to I2C RX buffer
|
||||
PSAL_I2C_USER_CB pUserCB; //Pointer to I2C User Callback
|
||||
PSAL_I2C_DMA_USER_DEF pDMAConf; //Pointer to I2C User Define DMA config
|
||||
}SAL_I2C_HND, *PSAL_I2C_HND;
|
||||
|
||||
|
||||
|
||||
//======================================================
|
||||
// I2C SAL Function Prototypes
|
||||
|
||||
// For checking I2C input index valid or not
|
||||
static inline HAL_Status
|
||||
RtkI2CIdxChk(
|
||||
IN uint8_t I2CIdx
|
||||
)
|
||||
{
|
||||
if (I2CIdx > I2C3_SEL)
|
||||
return HAL_ERR_UNKNOWN;
|
||||
|
||||
return HAL_OK;
|
||||
}
|
||||
#if 0
|
||||
//For checking I2C operation type valid or not
|
||||
static inline HAL_Status
|
||||
RtkI2COpTypeChk(
|
||||
IN void *Data
|
||||
)
|
||||
{
|
||||
PSAL_I2C_HND pSalI2CHND = (PSAL_I2C_HND) Data;
|
||||
|
||||
if (pSalI2CHND->OpType == I2C_POLL_TYPE)
|
||||
return HAL_ERR_UNKNOWN;
|
||||
|
||||
if (pSalI2CHND->OpType == I2C_DMA_TYPE)
|
||||
return HAL_ERR_UNKNOWN;
|
||||
|
||||
if (pSalI2CHND->OpType == I2C_INTR_TYPE)
|
||||
return HAL_ERR_UNKNOWN;
|
||||
|
||||
pSalI2CHND = pSalI2CHND;
|
||||
|
||||
return HAL_OK;
|
||||
}
|
||||
#endif
|
||||
//For checking I2C DMA available or not
|
||||
static inline HAL_Status
|
||||
RtkI2CDMAChk(
|
||||
IN void *Data
|
||||
)
|
||||
{
|
||||
PSAL_I2C_HND pSalI2CHND = (PSAL_I2C_HND) Data;
|
||||
|
||||
if (pSalI2CHND->OpType == I2C_DMA_TYPE) {
|
||||
if (pSalI2CHND->DevNum >= I2C2_SEL)
|
||||
return HAL_ERR_UNKNOWN;
|
||||
}
|
||||
else {
|
||||
return HAL_ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
//For checking I2C DMA available or not
|
||||
static inline HAL_Status
|
||||
RtkI2CDMAInitChk(
|
||||
IN void *Data
|
||||
)
|
||||
{
|
||||
PSAL_I2C_HND pSalI2CHND = (PSAL_I2C_HND) Data;
|
||||
|
||||
if (pSalI2CHND->OpType != I2C_DMA_TYPE) {
|
||||
return HAL_ERR_UNKNOWN;
|
||||
}
|
||||
else {
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//======================================================
|
||||
//SAL I2C management function prototype
|
||||
_LONG_CALL_ROM_ HAL_Status RtkI2CLoadDefault(IN void *Data);
|
||||
_LONG_CALL_ROM_ HAL_Status RtkI2CInit(IN void *Data);
|
||||
_LONG_CALL_ROM_ HAL_Status RtkI2CDeInit(IN void *Data);
|
||||
_LONG_CALL_ROM_ HAL_Status RtkI2CSend(IN void *Data);
|
||||
_LONG_CALL_ROM_ HAL_Status RtkI2CReceive(IN void *Data);
|
||||
_LONG_CALL_ROM_ void RtkSalI2COpInit(IN void *Data);
|
||||
_LONG_CALL_ROM_ HAL_Status RtkI2CSendUserAddr(IN void *Data,IN uint8_t MtrWr);
|
||||
_LONG_CALL_ROM_ HAL_Status RtkI2CIoCtrl(IN void *Data);
|
||||
_LONG_CALL_ROM_ HAL_Status RtkI2CPowerCtrl(IN void *Data);
|
||||
_LONG_CALL_ HAL_Status RtkI2CInitForPS(IN void *Data);
|
||||
_LONG_CALL_ HAL_Status RtkI2CDeInitForPS(IN void *Data);
|
||||
_LONG_CALL_ HAL_Status RtkI2CDisablePS(IN void *Data);
|
||||
_LONG_CALL_ HAL_Status RtkI2CEnablePS(IN void *Data);
|
||||
//================= I2C SAL END ===========================
|
||||
|
||||
|
||||
//================= I2C SAL MANAGEMENT START =================
|
||||
// I2C SAL management macros
|
||||
#define SAL_USER_CB_NUM (sizeof(SAL_I2C_USER_CB) / sizeof(PSAL_I2C_USERCB_ADPT))
|
||||
|
||||
//======================================================
|
||||
// I2C SAL management data structures
|
||||
// I2C SAL handle private
|
||||
typedef struct _SAL_I2C_HND_PRIV_ {
|
||||
void **ppSalI2CHnd; //Pointer to SAL_I2C_HND pointer
|
||||
SAL_I2C_HND SalI2CHndPriv; //Private SAL_I2C_HND
|
||||
}SAL_I2C_HND_PRIV, *PSAL_I2C_HND_PRIV;
|
||||
|
||||
//I2C SAL management adapter
|
||||
typedef struct _SAL_I2C_MNGT_ADPT_ {
|
||||
PSAL_I2C_HND_PRIV pSalHndPriv; //Pointer to SAL_I2C_HND
|
||||
PHAL_I2C_INIT_DAT pHalInitDat; //Pointer to HAL I2C initial data( HAL_I2C_INIT_DAT )
|
||||
PHAL_I2C_OP pHalOp; //Pointer to HAL I2C operation( HAL_I2C_OP )
|
||||
void (*pHalOpInit)(void*); //Pointer to HAL I2C initialize function
|
||||
PIRQ_HANDLE pIrqHnd; //Pointer to IRQ handler in SAL layer( IRQ_HANDLE )
|
||||
PSAL_I2C_USER_CB pUserCB; //Pointer to SAL user callbacks (SAL_I2C_USER_CB )
|
||||
volatile uint32_t MstRDCmdCnt; //Used for Master Read command count
|
||||
volatile uint32_t InnerTimeOut; //Used for SAL internal timeout count
|
||||
void (*pSalIrqFunc)(void*); //Used for SAL I2C interrupt function
|
||||
|
||||
PSAL_I2C_DMA_USER_DEF pDMAConf; //Pointer to I2C User Define DMA config
|
||||
PHAL_GDMA_ADAPTER pHalTxGdmaAdp; //Pointer to HAL_GDMA_ADAPTER
|
||||
PHAL_GDMA_ADAPTER pHalRxGdmaAdp; //Pointer to HAL_GDMA_ADAPTER
|
||||
PHAL_GDMA_OP pHalGdmaOp; //Pointer to HAL_GDMA_OP
|
||||
void (*pHalGdmaOpInit)(void*); //Pointer to HAL I2C initialize function
|
||||
PIRQ_HANDLE pIrqTxGdmaHnd; //Pointer to IRQ handler for Tx GDMA
|
||||
PIRQ_HANDLE pIrqRxGdmaHnd; //Pointer to IRQ handler for Rx GDMA
|
||||
void (*pSalDMATxIrqFunc)(void*); //Used for SAL I2C interrupt function
|
||||
void (*pSalDMARxIrqFunc)(void*); //Used for SAL I2C interrupt function
|
||||
uint32_t RSVD; //Reserved
|
||||
}SAL_I2C_MNGT_ADPT, *PSAL_I2C_MNGT_ADPT;
|
||||
|
||||
//======================================================
|
||||
//SAL I2C management function prototype
|
||||
PSAL_I2C_MNGT_ADPT RtkI2CGetMngtAdpt(IN uint8_t I2CIdx);
|
||||
HAL_Status RtkI2CFreeMngtAdpt(IN PSAL_I2C_MNGT_ADPT pSalI2CMngtAdpt);
|
||||
PSAL_I2C_HND RtkI2CGetSalHnd(IN uint8_t I2CIdx);
|
||||
HAL_Status RtkI2CFreeSalHnd(IN PSAL_I2C_HND pSalI2CHND);
|
||||
uint32_t RtkSalI2CSts(IN void *Data);
|
||||
|
||||
extern _LONG_CALL_ void I2CISRHandle(IN void *Data);
|
||||
extern _LONG_CALL_ void I2CTXGDMAISRHandle(IN void *Data);
|
||||
extern _LONG_CALL_ void I2CRXGDMAISRHandle(IN void *Data);
|
||||
extern HAL_Status I2CIsTimeout (IN uint32_t StartCount, IN uint32_t TimeoutCnt);
|
||||
extern HAL_TIMER_OP HalTimerOp;
|
||||
//======================================================
|
||||
// Function Prototypes
|
||||
_LONG_CALL_ void HalI2COpInit(IN void *Data);
|
||||
//================= I2C SAL MANAGEMENT END ==================
|
||||
|
||||
//================= Rtl8195a I2C V02 function prototype ============
|
||||
_LONG_CALL_ void HalI2COpInitV02(IN void *Data);
|
||||
_LONG_CALL_ void I2CISRHandleV02(IN void *Data);
|
||||
_LONG_CALL_ HAL_Status RtkI2CSendV02(IN void *Data);
|
||||
_LONG_CALL_ HAL_Status RtkI2CReceiveV02(IN void *Data);
|
||||
_LONG_CALL_ void RtkSalI2COpInitV02(IN void *Data);
|
||||
//================= Rtl8195a I2C V02 function prototype END==========
|
||||
|
||||
//================= Rtl8195a I2C V04 function prototype ============
|
||||
_LONG_CALL_ void HalI2COpInit_V04(IN void *Data);
|
||||
_LONG_CALL_ void I2CISRHandle_V04(IN void *Data);
|
||||
//================= Rtl8195a I2C V04 function prototype END==========
|
||||
|
||||
//======================================================
|
||||
//SAL I2C patch function prototype
|
||||
HAL_Status RtkI2CSend_Patch(IN void *Data);
|
||||
HAL_Status RtkI2CReceive_Patch(IN void *Data);
|
||||
void HalI2COpInit_Patch(IN void *Data);
|
||||
void I2CISRHandle_Patch(IN void *Data);
|
||||
|
||||
#ifndef CONFIG_RELEASE_BUILD_LIBRARIES
|
||||
#define RtkI2CSend RtkI2CSend_Patch
|
||||
#define RtkI2CReceive RtkI2CReceive_Patch
|
||||
#endif
|
||||
HAL_Status RtkI2CSend_Patch(IN void *Data);
|
||||
HAL_Status RtkI2CReceive_Patch(IN void *Data);
|
||||
//================= I2C SAL END ===========================
|
||||
|
||||
#endif //#ifndef _HAL_I2C_H_
|
||||
562
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_i2s.c
Normal file
562
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_i2s.c
Normal file
|
|
@ -0,0 +1,562 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
|
||||
#include "rtl8195a.h"
|
||||
#include "hal_i2s.h"
|
||||
#include "rand.h"
|
||||
#include "rtl_utility.h"
|
||||
|
||||
#ifdef CONFIG_I2S_EN
|
||||
|
||||
//1 need to be modified
|
||||
|
||||
|
||||
/*======================================================
|
||||
Local used variables
|
||||
*/
|
||||
SRAM_BF_DATA_SECTION
|
||||
HAL_I2S_OP HalI2SOpSAL={0};
|
||||
|
||||
|
||||
void
|
||||
I2SISRHandle(
|
||||
IN void *Data
|
||||
)
|
||||
{
|
||||
PHAL_I2S_ADAPTER pI2SAdp = (PHAL_I2S_ADAPTER) Data;
|
||||
PHAL_I2S_OP pHalI2SOP = &HalI2SOpSAL;
|
||||
PHAL_I2S_INIT_DAT pI2SCfg = pI2SAdp->pInitDat;
|
||||
uint32_t I2STxIsr, I2SRxIsr;
|
||||
uint8_t I2SPageNum = pI2SCfg->I2SPageNum+1;
|
||||
// uint32_t I2SPageSize = (pI2SAdp->I2SPageSize+1)<<2;
|
||||
uint32_t i;
|
||||
uint32_t pbuf;
|
||||
|
||||
I2STxIsr = pHalI2SOP->HalI2SReadReg(pI2SCfg, REG_I2S_TX_STATUS_INT);
|
||||
I2SRxIsr = pHalI2SOP->HalI2SReadReg(pI2SCfg, REG_I2S_RX_STATUS_INT);
|
||||
|
||||
pI2SCfg->I2STxIntrClr = I2STxIsr;
|
||||
pI2SCfg->I2SRxIntrClr = I2SRxIsr;
|
||||
pHalI2SOP->HalI2SClrIntr(pI2SCfg);
|
||||
|
||||
for (i=0 ; i<I2SPageNum ; i++) { // page 0, 1, 2, 3
|
||||
if (I2STxIsr & (1<<pI2SCfg->I2SHWTxIdx)) {
|
||||
// pbuf = ((uint32_t)(pI2SCfg->I2STxData)) + (I2SPageSize*pI2SCfg->I2SHWTxIdx);
|
||||
pbuf = (uint32_t)pI2SAdp->TxPageList[pI2SCfg->I2SHWTxIdx];
|
||||
pI2SAdp->UserCB.TxCCB(pI2SAdp->UserCB.TxCBId, (char*)pbuf);
|
||||
I2STxIsr &= ~(1<<pI2SCfg->I2SHWTxIdx);
|
||||
pI2SCfg->I2SHWTxIdx += 1;
|
||||
if (pI2SCfg->I2SHWTxIdx == I2SPageNum) {
|
||||
pI2SCfg->I2SHWTxIdx = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (I2SRxIsr & (1<<pI2SCfg->I2SHWRxIdx)) {
|
||||
// pbuf = ((uint32_t)(pI2SCfg->I2SRxData)) + (I2SPageSize*pI2SCfg->I2SHWRxIdx);
|
||||
pbuf = (uint32_t)pI2SAdp->RxPageList[pI2SCfg->I2SHWRxIdx];
|
||||
pI2SAdp->UserCB.RxCCB(pI2SAdp->UserCB.RxCBId, (char*)pbuf);
|
||||
I2SRxIsr &= ~(1<<pI2SCfg->I2SHWRxIdx);
|
||||
pI2SCfg->I2SHWRxIdx += 1;
|
||||
if (pI2SCfg->I2SHWRxIdx == I2SPageNum) {
|
||||
pI2SCfg->I2SHWRxIdx = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static HAL_Status
|
||||
RtkI2SIrqInit(
|
||||
IN PHAL_I2S_ADAPTER pI2SAdapter
|
||||
)
|
||||
{
|
||||
PIRQ_HANDLE pIrqHandle;
|
||||
|
||||
if (pI2SAdapter->DevNum > I2S_MAX_ID) {
|
||||
DBG_I2S_ERR("RtkI2SIrqInit: Invalid I2S Index(&d)\r\n", pI2SAdapter->DevNum);
|
||||
return HAL_ERR_PARA;
|
||||
}
|
||||
|
||||
pIrqHandle = &pI2SAdapter->IrqHandle;
|
||||
|
||||
switch (pI2SAdapter->DevNum){
|
||||
case I2S0_SEL:
|
||||
pIrqHandle->IrqNum = I2S0_PCM0_IRQ;
|
||||
break;
|
||||
|
||||
case I2S1_SEL:
|
||||
pIrqHandle->IrqNum = I2S1_PCM1_IRQ;
|
||||
break;
|
||||
|
||||
default:
|
||||
return HAL_ERR_PARA;
|
||||
}
|
||||
|
||||
pIrqHandle->Data = (uint32_t) (pI2SAdapter);
|
||||
pIrqHandle->IrqFun = (IRQ_FUN) I2SISRHandle;
|
||||
pIrqHandle->Priority = 6;
|
||||
InterruptRegister(pIrqHandle);
|
||||
InterruptEn(pIrqHandle);
|
||||
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
static HAL_Status
|
||||
RtkI2SIrqDeInit(
|
||||
IN PHAL_I2S_ADAPTER pI2SAdapter
|
||||
)
|
||||
{
|
||||
if (pI2SAdapter->DevNum > I2S_MAX_ID) {
|
||||
DBG_I2S_ERR("RtkI2SIrqDeInit: Invalid I2S Index(&d)\r\n", pI2SAdapter->DevNum);
|
||||
return HAL_ERR_PARA;
|
||||
}
|
||||
|
||||
InterruptDis(&pI2SAdapter->IrqHandle);
|
||||
InterruptUnRegister(&pI2SAdapter->IrqHandle);
|
||||
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
static HAL_Status
|
||||
RtkI2SPinMuxInit(
|
||||
IN PHAL_I2S_ADAPTER pI2SAdapter
|
||||
)
|
||||
{
|
||||
uint32_t I2Stemp;
|
||||
|
||||
if (pI2SAdapter->DevNum > I2S_MAX_ID) {
|
||||
DBG_I2S_ERR("RtkI2SPinMuxInit: Invalid I2S Index(&d)\r\n", pI2SAdapter->DevNum);
|
||||
return HAL_ERR_PARA;
|
||||
}
|
||||
|
||||
// enable system pll
|
||||
I2Stemp = HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_SYSPLL_CTRL1) | (1<<9) | (1<<10);
|
||||
HAL_WRITE32(SYSTEM_CTRL_BASE, REG_SYS_SYSPLL_CTRL1, I2Stemp);
|
||||
|
||||
switch (pI2SAdapter->DevNum){
|
||||
case I2S0_SEL:
|
||||
ACTCK_I2S_CCTRL(ON);
|
||||
SLPCK_I2S_CCTRL(ON);
|
||||
LXBUS_FCTRL(ON); // enable lx bus for i2s
|
||||
|
||||
/*I2S0 Pin Mux Setting*/
|
||||
PinCtrl(I2S0, pI2SAdapter->PinMux, ON);
|
||||
if (pI2SAdapter->PinMux == I2S_S0) {
|
||||
DBG_I2S_WARN(ANSI_COLOR_MAGENTA"I2S0 Pin may conflict with JTAG\r\n"ANSI_COLOR_RESET);
|
||||
}
|
||||
I2S0_MCK_CTRL(ON);
|
||||
I2S0_PIN_CTRL(ON);
|
||||
I2S0_FCTRL(ON);
|
||||
|
||||
break;
|
||||
case I2S1_SEL:
|
||||
ACTCK_I2S_CCTRL(ON);
|
||||
SLPCK_I2S_CCTRL(ON);
|
||||
LXBUS_FCTRL(ON); // enable lx bus for i2s
|
||||
|
||||
/*I2S1 Pin Mux Setting*/
|
||||
PinCtrl(I2S1, pI2SAdapter->PinMux, ON);
|
||||
if (pI2SAdapter->PinMux == I2S_S2) {
|
||||
DBG_I2S_WARN(ANSI_COLOR_MAGENTA"I2S1 Pin may conflict with JTAG\r\n"ANSI_COLOR_RESET);
|
||||
}
|
||||
I2S1_MCK_CTRL(ON);
|
||||
I2S1_PIN_CTRL(ON);
|
||||
I2S0_FCTRL(ON); //i2s 1 is control by bit 24 BIT_PERI_I2S0_EN
|
||||
I2S1_FCTRL(ON);
|
||||
break;
|
||||
default:
|
||||
return HAL_ERR_PARA;
|
||||
}
|
||||
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
|
||||
static HAL_Status
|
||||
RtkI2SPinMuxDeInit(
|
||||
IN PHAL_I2S_ADAPTER pI2SAdapter
|
||||
)
|
||||
{
|
||||
if (pI2SAdapter->DevNum > I2S_MAX_ID) {
|
||||
DBG_I2S_ERR("RtkI2SPinMuxDeInit: Invalid I2S Index(&d)\r\n", pI2SAdapter->DevNum);
|
||||
return HAL_ERR_PARA;
|
||||
}
|
||||
|
||||
switch (pI2SAdapter->DevNum){
|
||||
case I2S0_SEL:
|
||||
/*I2S0 Pin Mux Setting*/
|
||||
//ACTCK_I2C0_CCTRL(OFF);
|
||||
PinCtrl(I2S0, pI2SAdapter->PinMux, OFF);
|
||||
I2S0_MCK_CTRL(OFF);
|
||||
I2S0_PIN_CTRL(OFF);
|
||||
//I2S0_FCTRL(OFF);
|
||||
|
||||
break;
|
||||
case I2S1_SEL:
|
||||
/*I2S1 Pin Mux Setting*/
|
||||
//ACTCK_I2C1_CCTRL(OFF);
|
||||
PinCtrl(I2S1, pI2SAdapter->PinMux, OFF);
|
||||
I2S1_MCK_CTRL(OFF);
|
||||
I2S1_PIN_CTRL(OFF);
|
||||
//I2S1_FCTRL(OFF);
|
||||
break;
|
||||
default:
|
||||
return HAL_ERR_PARA;
|
||||
}
|
||||
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
|
||||
HAL_Status
|
||||
RtkI2SInit(
|
||||
IN void *Data
|
||||
)
|
||||
{
|
||||
PHAL_I2S_ADAPTER pI2SAdapter = (PHAL_I2S_ADAPTER) Data;
|
||||
PHAL_I2S_OP pHalI2SOP = &HalI2SOpSAL;
|
||||
PHAL_I2S_INIT_DAT pI2SCfg;
|
||||
|
||||
if (pI2SAdapter == 0) {
|
||||
DBG_I2S_ERR("RtkI2SInit: Null Pointer\r\n");
|
||||
return HAL_ERR_PARA;
|
||||
}
|
||||
|
||||
if (pI2SAdapter->DevNum > I2S_MAX_ID) {
|
||||
DBG_I2S_ERR("RtkI2SInit: Invalid I2S Index(&d)\r\n", pI2SAdapter->DevNum);
|
||||
return HAL_ERR_PARA;
|
||||
}
|
||||
|
||||
pI2SCfg = pI2SAdapter->pInitDat;
|
||||
|
||||
/*I2S Initialize HAL Operations*/
|
||||
HalI2SOpInit(pHalI2SOP);
|
||||
|
||||
/*I2S Interrupt Initialization*/
|
||||
RtkI2SIrqInit(pI2SAdapter);
|
||||
|
||||
/*I2S Pin Mux Initialization*/
|
||||
RtkI2SPinMuxInit(pI2SAdapter);
|
||||
|
||||
/*I2S Load User Setting*/
|
||||
pI2SCfg->I2SIdx = pI2SAdapter->DevNum;
|
||||
|
||||
/*I2S HAL Initialization*/
|
||||
pHalI2SOP->HalI2SInit(pI2SCfg);
|
||||
|
||||
/*I2S Device Status Update*/
|
||||
pI2SAdapter->DevSts = I2S_STS_INITIALIZED;
|
||||
|
||||
/*I2S Enable Module*/
|
||||
pI2SCfg->I2SEn = I2S_ENABLE;
|
||||
pHalI2SOP->HalI2SEnable(pI2SCfg);
|
||||
|
||||
/*I2S Device Status Update*/
|
||||
pI2SAdapter->DevSts = I2S_STS_IDLE;
|
||||
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
HAL_Status
|
||||
RtkI2SDeInit(
|
||||
IN void *Data
|
||||
)
|
||||
{
|
||||
PHAL_I2S_ADAPTER pI2SAdapter = (PHAL_I2S_ADAPTER) Data;
|
||||
PHAL_I2S_OP pHalI2SOP = &HalI2SOpSAL;
|
||||
PHAL_I2S_INIT_DAT pI2SCfg;
|
||||
uint32_t I2Stemp;
|
||||
|
||||
if (pI2SAdapter == 0) {
|
||||
DBG_I2S_ERR("RtkI2SDeInit: Null Pointer\r\n");
|
||||
return HAL_ERR_PARA;
|
||||
}
|
||||
|
||||
pI2SCfg = pI2SAdapter->pInitDat;
|
||||
|
||||
/*I2S Disable Module*/
|
||||
pI2SCfg->I2SEn = I2S_DISABLE;
|
||||
pHalI2SOP->HalI2SEnable(pI2SCfg);
|
||||
HalI2SClearAllOwnBit((void*)pI2SCfg);
|
||||
|
||||
/*I2C HAL DeInitialization*/
|
||||
//pHalI2SOP->HalI2SDeInit(pI2SCfg);
|
||||
|
||||
/*I2S Interrupt DeInitialization*/
|
||||
RtkI2SIrqDeInit(pI2SAdapter);
|
||||
|
||||
/*I2S Pin Mux DeInitialization*/
|
||||
RtkI2SPinMuxDeInit(pI2SAdapter);
|
||||
|
||||
/*I2S HAL DeInitialization*/
|
||||
pHalI2SOP->HalI2SDeInit(pI2SCfg);
|
||||
|
||||
/*I2S CLK Source Close*/
|
||||
I2Stemp = HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_SYSPLL_CTRL1) & (~((1<<9) | (1<<10)));
|
||||
HAL_WRITE32(SYSTEM_CTRL_BASE, REG_SYS_SYSPLL_CTRL1, I2Stemp);
|
||||
|
||||
/*I2S Device Status Update*/
|
||||
pI2SAdapter->DevSts = I2S_STS_UNINITIAL;
|
||||
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
HAL_Status
|
||||
RtkI2SEnable(
|
||||
IN void *Data
|
||||
)
|
||||
{
|
||||
PHAL_I2S_ADAPTER pI2SAdapter = (PHAL_I2S_ADAPTER) Data;
|
||||
PHAL_I2S_OP pHalI2SOP = &HalI2SOpSAL;
|
||||
PHAL_I2S_INIT_DAT pI2SCfg;
|
||||
uint32_t I2Stemp;
|
||||
|
||||
// Enable IP Clock
|
||||
I2Stemp = HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_SYSPLL_CTRL1) | (1<<9) | (1<<10);
|
||||
HAL_WRITE32(SYSTEM_CTRL_BASE, REG_SYS_SYSPLL_CTRL1, I2Stemp);
|
||||
ACTCK_I2S_CCTRL(ON);
|
||||
SLPCK_I2S_CCTRL(ON);
|
||||
|
||||
pI2SCfg = pI2SAdapter->pInitDat;
|
||||
pI2SCfg->I2SEn = I2S_ENABLE;
|
||||
pHalI2SOP->HalI2SEnable(pI2SCfg);
|
||||
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
HAL_Status
|
||||
RtkI2SDisable(
|
||||
IN void *Data
|
||||
)
|
||||
{
|
||||
PHAL_I2S_ADAPTER pI2SAdapter = (PHAL_I2S_ADAPTER) Data;
|
||||
PHAL_I2S_OP pHalI2SOP = &HalI2SOpSAL;
|
||||
PHAL_I2S_INIT_DAT pI2SCfg;
|
||||
uint32_t I2Stemp;
|
||||
|
||||
pI2SCfg = pI2SAdapter->pInitDat;
|
||||
pI2SCfg->I2SEn = I2S_DISABLE;
|
||||
pHalI2SOP->HalI2SEnable(pI2SCfg);
|
||||
|
||||
// Gate IP Clock
|
||||
ACTCK_I2S_CCTRL(OFF);
|
||||
SLPCK_I2S_CCTRL(OFF);
|
||||
|
||||
// Close I2S bus clock(WS,SCLK,MCLK). If needs that clock, mark this.
|
||||
I2Stemp = HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_SYSPLL_CTRL1) & (~((1<<9) | (1<<10)));
|
||||
HAL_WRITE32(SYSTEM_CTRL_BASE, REG_SYS_SYSPLL_CTRL1, I2Stemp);
|
||||
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
RTK_STATUS
|
||||
RtkI2SIoCtrl(
|
||||
IN void *Data
|
||||
)
|
||||
{
|
||||
return _EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
RTK_STATUS
|
||||
RtkI2SPowerCtrl(
|
||||
IN void *Data
|
||||
)
|
||||
{
|
||||
return _EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
HAL_Status
|
||||
RtkI2SLoadDefault(
|
||||
IN void *Adapter,
|
||||
IN void *Setting
|
||||
)
|
||||
{
|
||||
PHAL_I2S_ADAPTER pI2SAdapter = (PHAL_I2S_ADAPTER) Adapter;
|
||||
PHAL_I2S_INIT_DAT pI2SCfg = pI2SAdapter->pInitDat;
|
||||
PHAL_I2S_DEF_SETTING pLoadSetting = (PHAL_I2S_DEF_SETTING)Setting;
|
||||
|
||||
if (pI2SAdapter == 0) {
|
||||
DBG_I2S_ERR("RtkI2SLoadDefault: Null Pointer\r\n");
|
||||
return HAL_ERR_PARA;
|
||||
}
|
||||
|
||||
if (pI2SAdapter->pInitDat == NULL) {
|
||||
DBG_I2S_ERR("RtkI2SLoadDefault: pInitDat is NULL!\r\n", pI2SAdapter->DevNum);
|
||||
return HAL_ERR_PARA;
|
||||
}
|
||||
|
||||
pI2SAdapter->DevSts = pLoadSetting->DevSts;
|
||||
pI2SAdapter->ErrType = 0;
|
||||
pI2SAdapter->TimeOut = 0;
|
||||
|
||||
pI2SCfg->I2SIdx = pI2SAdapter->DevNum;
|
||||
pI2SCfg->I2SEn = I2S_DISABLE;
|
||||
pI2SCfg->I2SMaster = pLoadSetting->I2SMaster;
|
||||
pI2SCfg->I2SWordLen = pLoadSetting->I2SWordLen;
|
||||
pI2SCfg->I2SChNum = pLoadSetting->I2SChNum;
|
||||
pI2SCfg->I2SPageNum = pLoadSetting->I2SPageNum;
|
||||
pI2SCfg->I2SPageSize = pLoadSetting->I2SPageSize;
|
||||
pI2SCfg->I2SRate = pLoadSetting->I2SRate;
|
||||
pI2SCfg->I2STRxAct = pLoadSetting->I2STRxAct;
|
||||
pI2SCfg->I2STxIntrMSK = pLoadSetting->I2STxIntrMSK;
|
||||
pI2SCfg->I2SRxIntrMSK = pLoadSetting->I2SRxIntrMSK;
|
||||
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
void HalI2SOpInit(
|
||||
IN void *Data
|
||||
)
|
||||
{
|
||||
PHAL_I2S_OP pHalI2SOp = (PHAL_I2S_OP) Data;
|
||||
|
||||
pHalI2SOp->HalI2SDeInit = HalI2SDeInitRtl8195a;
|
||||
pHalI2SOp->HalI2STx = HalI2STxRtl8195a;
|
||||
pHalI2SOp->HalI2SRx = HalI2SRxRtl8195a;
|
||||
pHalI2SOp->HalI2SEnable = HalI2SEnableRtl8195a;
|
||||
pHalI2SOp->HalI2SIntrCtrl = HalI2SIntrCtrlRtl8195a;
|
||||
pHalI2SOp->HalI2SReadReg = HalI2SReadRegRtl8195a;
|
||||
pHalI2SOp->HalI2SClrIntr = HalI2SClrIntrRtl8195a;
|
||||
pHalI2SOp->HalI2SClrAllIntr = HalI2SClrAllIntrRtl8195a;
|
||||
pHalI2SOp->HalI2SDMACtrl = HalI2SDMACtrlRtl8195a;
|
||||
|
||||
#ifndef CONFIG_CHIP_E_CUT
|
||||
pHalI2SOp->HalI2SInit = HalI2SInitRtl8195a_Patch;
|
||||
pHalI2SOp->HalI2SSetRate = HalI2SSetRateRtl8195a;
|
||||
pHalI2SOp->HalI2SSetWordLen = HalI2SSetWordLenRtl8195a;
|
||||
pHalI2SOp->HalI2SSetChNum = HalI2SSetChNumRtl8195a;
|
||||
pHalI2SOp->HalI2SSetPageNum = HalI2SSetPageNumRtl8195a;
|
||||
pHalI2SOp->HalI2SSetPageSize = HalI2SSetPageSizeRtl8195a;
|
||||
#else
|
||||
pHalI2SOp->HalI2SInit = HalI2SInitRtl8195a_V04;
|
||||
pHalI2SOp->HalI2SSetRate = HalI2SSetRateRtl8195a_V04;
|
||||
pHalI2SOp->HalI2SSetWordLen = HalI2SSetWordLenRtl8195a_V04;
|
||||
pHalI2SOp->HalI2SSetChNum = HalI2SSetChNumRtl8195a_V04;
|
||||
pHalI2SOp->HalI2SSetPageNum = HalI2SSetPageNumRtl8195a_V04;
|
||||
pHalI2SOp->HalI2SSetPageSize = HalI2SSetPageSizeRtl8195a_V04;
|
||||
#endif // #ifndef CONFIG_CHIP_E_CUT
|
||||
}
|
||||
|
||||
HAL_Status
|
||||
HalI2SInit(
|
||||
IN void *Data
|
||||
)
|
||||
{
|
||||
HAL_Status ret;
|
||||
PHAL_I2S_ADAPTER pI2SAdapter = (PHAL_I2S_ADAPTER) Data;
|
||||
uint32_t Function;
|
||||
uint8_t funret;
|
||||
|
||||
#ifdef CONFIG_SOC_PS_MODULE
|
||||
REG_POWER_STATE I2sPwrState;
|
||||
#endif
|
||||
|
||||
if(pI2SAdapter->DevNum == 0){
|
||||
Function = I2S0;
|
||||
}
|
||||
else {
|
||||
Function = I2S1;
|
||||
}
|
||||
|
||||
funret = FunctionChk(Function, (uint32_t)pI2SAdapter->PinMux);
|
||||
|
||||
if (funret == _FALSE){
|
||||
return HAL_ERR_HW;
|
||||
}
|
||||
|
||||
ret = RtkI2SInit(Data);
|
||||
#ifdef CONFIG_SOC_PS_MODULE
|
||||
if(ret == HAL_OK) {
|
||||
// To register a new peripheral device power state
|
||||
I2sPwrState.FuncIdx = I2S0 + pI2SAdapter->DevNum;
|
||||
I2sPwrState.PwrState = ACT;
|
||||
RegPowerState(I2sPwrState);
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
HalI2SDeInit(
|
||||
IN void *Data
|
||||
)
|
||||
{
|
||||
#ifdef CONFIG_SOC_PS_MODULE
|
||||
REG_POWER_STATE I2sPwrState;
|
||||
PHAL_I2S_ADAPTER pI2SAdapter = (PHAL_I2S_ADAPTER) Data;
|
||||
uint8_t HwState;
|
||||
|
||||
I2sPwrState.FuncIdx = I2S0 + pI2SAdapter->DevNum;
|
||||
QueryRegPwrState(I2sPwrState.FuncIdx, &(I2sPwrState.PwrState), &HwState);
|
||||
|
||||
// if the power state isn't ACT, then switch the power state back to ACT first
|
||||
if ((I2sPwrState.PwrState != ACT) && (I2sPwrState.PwrState != INACT)) {
|
||||
HalI2SEnable(Data);
|
||||
QueryRegPwrState(I2sPwrState.FuncIdx, &(I2sPwrState.PwrState), &HwState);
|
||||
}
|
||||
|
||||
if (I2sPwrState.PwrState == ACT) {
|
||||
I2sPwrState.PwrState = INACT;
|
||||
RegPowerState(I2sPwrState);
|
||||
}
|
||||
#endif
|
||||
|
||||
RtkI2SDeInit(Data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
HAL_Status
|
||||
HalI2SDisable(
|
||||
IN void *Data
|
||||
)
|
||||
{
|
||||
HAL_Status ret;
|
||||
#ifdef CONFIG_SOC_PS_MODULE
|
||||
REG_POWER_STATE I2sPwrState;
|
||||
PHAL_I2S_ADAPTER pI2SAdapter = (PHAL_I2S_ADAPTER) Data;
|
||||
#endif
|
||||
|
||||
ret = RtkI2SDisable(Data);
|
||||
#ifdef CONFIG_SOC_PS_MODULE
|
||||
if (ret == HAL_OK) {
|
||||
I2sPwrState.FuncIdx = I2S0 + pI2SAdapter->DevNum;
|
||||
I2sPwrState.PwrState = SLPCG;
|
||||
RegPowerState(I2sPwrState);
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
HAL_Status
|
||||
HalI2SEnable(
|
||||
IN void *Data
|
||||
)
|
||||
{
|
||||
HAL_Status ret;
|
||||
#ifdef CONFIG_SOC_PS_MODULE
|
||||
REG_POWER_STATE I2sPwrState;
|
||||
PHAL_I2S_ADAPTER pI2SAdapter = (PHAL_I2S_ADAPTER) Data;
|
||||
#endif
|
||||
|
||||
ret = RtkI2SEnable(Data);
|
||||
#ifdef CONFIG_SOC_PS_MODULE
|
||||
if (ret == HAL_OK) {
|
||||
I2sPwrState.FuncIdx = I2S0 + pI2SAdapter->DevNum;
|
||||
I2sPwrState.PwrState = ACT;
|
||||
RegPowerState(I2sPwrState);
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif // CONFIG_I2S_EN
|
||||
347
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_i2s.h
Normal file
347
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_i2s.h
Normal file
|
|
@ -0,0 +1,347 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _HAL_I2S_H_
|
||||
#define _HAL_I2S_H_
|
||||
|
||||
#include "rtl8195a_i2s.h"
|
||||
|
||||
/* User Define Flags */
|
||||
|
||||
#define I2S_MAX_ID 1 // valid I2S index 0 ~ I2S_MAX_ID
|
||||
|
||||
/**********************************************************************/
|
||||
/* I2S HAL initial data structure */
|
||||
typedef struct _HAL_I2S_INIT_DAT_ {
|
||||
uint8_t I2SIdx; /*I2S index used*/
|
||||
uint8_t I2SEn; /*I2S module enable tx/rx/tx+rx*/
|
||||
uint8_t I2SMaster; /*I2S Master or Slave mode*/
|
||||
uint8_t I2SWordLen; /*I2S Word length 16 or 24bits*/
|
||||
|
||||
uint8_t I2SChNum; /*I2S Channel number mono or stereo*/
|
||||
uint8_t I2SPageNum; /*I2S Page Number 2~4*/
|
||||
uint16_t I2SPageSize; /*I2S page Size 1~4096 word*/
|
||||
|
||||
uint8_t *I2STxData; /*I2S Tx data pointer*/
|
||||
|
||||
uint8_t *I2SRxData; /*I2S Rx data pointer*/
|
||||
|
||||
uint32_t I2STxIntrMSK; /*I2S Tx Interrupt Mask*/
|
||||
uint32_t I2STxIntrClr; /*I2S Tx Interrupt register to clear */
|
||||
|
||||
uint32_t I2SRxIntrMSK; /*I2S Rx Interrupt Mask*/
|
||||
uint32_t I2SRxIntrClr; /*I2S Rx Interrupt register to clear*/
|
||||
|
||||
uint16_t I2STxIdx; /*I2S TX page index */
|
||||
uint16_t I2SRxIdx; /*I2S RX page index */
|
||||
|
||||
uint16_t I2SHWTxIdx; /*I2S HW TX page index */
|
||||
uint16_t I2SHWRxIdx; /*I2S HW RX page index */
|
||||
|
||||
|
||||
uint16_t I2SRate; /*I2S sample rate*/
|
||||
uint8_t I2STRxAct; /*I2S tx rx act*/
|
||||
}HAL_I2S_INIT_DAT, *PHAL_I2S_INIT_DAT;
|
||||
|
||||
/**********************************************************************/
|
||||
/* I2S Data Structures */
|
||||
/* I2S Module Selection */
|
||||
typedef enum _I2S_MODULE_SEL_ {
|
||||
I2S0_SEL = 0x0,
|
||||
I2S1_SEL = 0x1,
|
||||
}I2S_MODULE_SEL,*PI2S_MODULE_SEL;
|
||||
/*
|
||||
typedef struct _HAL_I2S_ADAPTER_ {
|
||||
uint32_t Enable:1;
|
||||
I2S_CTL_REG I2sCtl;
|
||||
I2S_SETTING_REG I2sSetting;
|
||||
uint32_t abc;
|
||||
uint8_t I2sIndex;
|
||||
}HAL_I2S_ADAPTER, *PHAL_I2S_ADAPTER;
|
||||
*/
|
||||
/* I2S HAL Operations */
|
||||
typedef struct _HAL_I2S_OP_ {
|
||||
RTK_STATUS (*HalI2SInit) (void *Data);
|
||||
RTK_STATUS (*HalI2SDeInit) (void *Data);
|
||||
RTK_STATUS (*HalI2STx) (void *Data, uint8_t *pBuff);
|
||||
RTK_STATUS (*HalI2SRx) (void *Data, uint8_t *pBuff);
|
||||
RTK_STATUS (*HalI2SEnable) (void *Data);
|
||||
RTK_STATUS (*HalI2SIntrCtrl) (void *Data);
|
||||
uint32_t (*HalI2SReadReg) (void *Data, uint8_t I2SReg);
|
||||
RTK_STATUS (*HalI2SSetRate) (void *Data);
|
||||
RTK_STATUS (*HalI2SSetWordLen) (void *Data);
|
||||
RTK_STATUS (*HalI2SSetChNum) (void *Data);
|
||||
RTK_STATUS (*HalI2SSetPageNum) (void *Data);
|
||||
RTK_STATUS (*HalI2SSetPageSize) (void *Data);
|
||||
|
||||
RTK_STATUS (*HalI2SClrIntr) (void *Data);
|
||||
RTK_STATUS (*HalI2SClrAllIntr) (void *Data);
|
||||
RTK_STATUS (*HalI2SDMACtrl) (void *Data);
|
||||
/*
|
||||
void (*HalI2sOnOff)(void *Data);
|
||||
BOOL (*HalI2sInit)(void *Data);
|
||||
BOOL (*HalI2sSetting)(void *Data);
|
||||
BOOL (*HalI2sEn)(void *Data);
|
||||
BOOL (*HalI2sIsrEnAndDis) (void *Data);
|
||||
BOOL (*HalI2sDumpReg)(void *Data);
|
||||
BOOL (*HalI2s)(void *Data);
|
||||
*/
|
||||
}HAL_I2S_OP, *PHAL_I2S_OP;
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
/* I2S Pinmux Selection */
|
||||
#if 0
|
||||
typedef enum _I2S0_PINMUX_ {
|
||||
I2S0_TO_S0 = 0x0,
|
||||
I2S0_TO_S1 = 0x1,
|
||||
I2S0_TO_S2 = 0x2,
|
||||
}I2S0_PINMUX, *PI2S0_PINMUX;
|
||||
|
||||
typedef enum _I2S1_PINMUX_ {
|
||||
I2S1_TO_S0 = 0x0,
|
||||
I2S1_TO_S1 = 0x1,
|
||||
}I2S1_PINMUX, *PI2S1_PINMUX;
|
||||
#endif
|
||||
|
||||
typedef enum _I2S_PINMUX_ {
|
||||
I2S_S0 = 0,
|
||||
I2S_S1 = 1,
|
||||
I2S_S2 = 2,
|
||||
I2S_S3 = 3
|
||||
}I2S_PINMUX, *PI2S_PINMUX;
|
||||
|
||||
|
||||
/* I2S Module Status */
|
||||
typedef enum _I2S_MODULE_STATUS_ {
|
||||
I2S_DISABLE = 0x0,
|
||||
I2S_ENABLE = 0x1,
|
||||
}I2S_MODULE_STATUS, *PI2S_MODULE_STATUS;
|
||||
|
||||
|
||||
/* I2S Device Status */
|
||||
typedef enum _I2S_Device_STATUS_ {
|
||||
I2S_STS_UNINITIAL = 0x00,
|
||||
I2S_STS_INITIALIZED = 0x01,
|
||||
I2S_STS_IDLE = 0x02,
|
||||
|
||||
I2S_STS_TX_READY = 0x03,
|
||||
I2S_STS_TX_ING = 0x04,
|
||||
|
||||
I2S_STS_RX_READY = 0x05,
|
||||
I2S_STS_RX_ING = 0x06,
|
||||
|
||||
I2S_STS_TRX_READY = 0x07,
|
||||
I2S_STS_TRX_ING = 0x08,
|
||||
|
||||
I2S_STS_ERROR = 0x09,
|
||||
}I2S_Device_STATUS, *PI2S_Device_STATUS;
|
||||
|
||||
|
||||
/* I2S Feature Status */
|
||||
typedef enum _I2S_FEATURE_STATUS_{
|
||||
I2S_FEATURE_DISABLED = 0,
|
||||
I2S_FEATURE_ENABLED = 1,
|
||||
}I2S_FEATURE_STATUS,*PI2S_FEATURE_STATUS;
|
||||
|
||||
/* I2S Device Mode */
|
||||
typedef enum _I2S_DEV_MODE_ {
|
||||
I2S_MASTER_MODE = 0x0,
|
||||
I2S_SLAVE_MODE = 0x1
|
||||
}I2S_DEV_MODE, *PI2S_DEV_MODE;
|
||||
|
||||
/* I2S Word Length */
|
||||
typedef enum _I2S_WORD_LEN_ {
|
||||
I2S_WL_16 = 0x0,
|
||||
I2S_WL_24 = 0x1,
|
||||
}I2S_WORD_LEN, *PI2S_WORD_LEN;
|
||||
|
||||
/* I2S Bus Transmit/Receive */
|
||||
typedef enum _I2S_DIRECTION_ {
|
||||
I2S_ONLY_RX = 0x0,
|
||||
I2S_ONLY_TX = 0x1,
|
||||
I2S_TXRX = 0x2
|
||||
}I2S_DIRECTION, *PI2S_DIRECTION;
|
||||
|
||||
/* I2S Channel number */
|
||||
typedef enum _I2S_CH_NUM_ {
|
||||
I2S_CH_STEREO = 0x0,
|
||||
I2S_CH_RSVD = 0x1,
|
||||
I2S_CH_MONO = 0x2
|
||||
}I2S_CH_NUM, *PI2S_CH_NUM;
|
||||
|
||||
/* I2S Page number */
|
||||
typedef enum _I2S_PAGE_NUM_ {
|
||||
I2S_1PAGE = 0x0,
|
||||
I2S_2PAGE = 0x1,
|
||||
I2S_3PAGE = 0x2,
|
||||
I2S_4PAGE = 0x3
|
||||
}I2S_PAGE_NUM, *PI2S_PAGE_NUM;
|
||||
|
||||
/* I2S Sample rate*/
|
||||
typedef enum _I2S_SAMPLE_RATE_ {
|
||||
I2S_SR_8KHZ = 0x00, // /12
|
||||
I2S_SR_16KHZ = 0x01, // /6
|
||||
I2S_SR_24KHZ = 0x02, // /4
|
||||
I2S_SR_32KHZ = 0x03, // /3
|
||||
I2S_SR_48KHZ = 0x05, // /2
|
||||
I2S_SR_96KHZ = 0x06, // x1, base 96kHz
|
||||
I2S_SR_7p35KHZ = 0x10,
|
||||
I2S_SR_11p02KHZ = 0x11,
|
||||
I2S_SR_22p05KHZ = 0x12,
|
||||
I2S_SR_29p4KHZ = 0x13,
|
||||
I2S_SR_44p1KHZ = 0x15,
|
||||
I2S_SR_88p2KHZ = 0x16 // x1, base 88200Hz
|
||||
}I2S_SAMPLE_RATE, *PI2S_SAMPLE_RATE;
|
||||
|
||||
/* I2S TX interrupt mask/status */
|
||||
typedef enum _I2S_TX_IMR_ {
|
||||
I2S_TX_INT_PAGE0_OK = (1<<0),
|
||||
I2S_TX_INT_PAGE1_OK = (1<<1),
|
||||
I2S_TX_INT_PAGE2_OK = (1<<2),
|
||||
I2S_TX_INT_PAGE3_OK = (1<<3),
|
||||
I2S_TX_INT_FULL = (1<<4),
|
||||
I2S_TX_INT_EMPTY = (1<<5)
|
||||
} I2S_TX_IMR, *PI2S_TX_IMR;
|
||||
|
||||
/* I2S RX interrupt mask/status */
|
||||
typedef enum _I2S_RX_IMR_ {
|
||||
I2S_RX_INT_PAGE0_OK = (1<<0),
|
||||
I2S_RX_INT_PAGE1_OK = (1<<1),
|
||||
I2S_RX_INT_PAGE2_OK = (1<<2),
|
||||
I2S_RX_INT_PAGE3_OK = (1<<3),
|
||||
I2S_RX_INT_EMPTY = (1<<4),
|
||||
I2S_RX_INT_FULL = (1<<5)
|
||||
} I2S_RX_IMR, *PI2S_RX_IMR;
|
||||
|
||||
/* I2S User Callbacks */
|
||||
typedef struct _SAL_I2S_USER_CB_{
|
||||
void (*TXCB) (void *Data);
|
||||
void (*TXCCB) (void *Data);
|
||||
void (*RXCB) (void *Data);
|
||||
void (*RXCCB) (void *Data);
|
||||
void (*RDREQCB) (void *Data);
|
||||
void (*ERRCB) (void *Data);
|
||||
void (*GENCALLCB) (void *Data);
|
||||
}SAL_I2S_USER_CB,*PSAL_I2S_USER_CB;
|
||||
|
||||
typedef struct _I2S_USER_CB_{
|
||||
void (*TxCCB)(uint32_t id, char *pbuf);
|
||||
uint32_t TxCBId;
|
||||
void (*RxCCB)(uint32_t id, char *pbuf);
|
||||
uint32_t RxCBId;
|
||||
}I2S_USER_CB,*PI2S_USER_CB;
|
||||
|
||||
/* Software API Level I2S Handler */
|
||||
typedef struct _HAL_I2S_ADAPTER_{
|
||||
uint8_t DevNum; //I2S device number
|
||||
uint8_t PinMux; //I2S pin mux seletion
|
||||
uint8_t RSVD0; //Reserved
|
||||
volatile uint8_t DevSts; //I2S device status
|
||||
|
||||
uint32_t RSVD2; //Reserved
|
||||
uint32_t I2SExd; //I2S extended options:
|
||||
//bit 0: I2C RESTART supported,
|
||||
// 0 for NOT supported,
|
||||
// 1 for supported
|
||||
//bit 1: I2C General Call supported
|
||||
// 0 for NOT supported,
|
||||
// 1 for supported
|
||||
//bit 2: I2C START Byte supported
|
||||
// 0 for NOT supported,
|
||||
// 1 for supported
|
||||
//bit 3: I2C Slave-No-Ack
|
||||
// supported
|
||||
// 0 for NOT supported,
|
||||
// 1 for supported
|
||||
//bit 4: I2C bus loading,
|
||||
// 0 for 100pf,
|
||||
// 1 for 400pf
|
||||
//bit 5: I2C slave ack to General
|
||||
// Call
|
||||
//bit 6: I2C User register address
|
||||
//bit 7: I2C 2-Byte User register
|
||||
// address
|
||||
//bit 31~bit 8: Reserved
|
||||
uint32_t ErrType; //
|
||||
uint32_t TimeOut; //I2S IO Timeout count
|
||||
|
||||
PHAL_I2S_INIT_DAT pInitDat; //Pointer to I2S initial data struct
|
||||
I2S_USER_CB UserCB; //Pointer to I2S User Callback
|
||||
IRQ_HANDLE IrqHandle; // Irq Handler
|
||||
|
||||
uint32_t* TxPageList[4]; // The Tx DAM buffer: pointer of each page
|
||||
uint32_t* RxPageList[4]; // The Tx DAM buffer: pointer of each page
|
||||
}HAL_I2S_ADAPTER, *PHAL_I2S_ADAPTER;
|
||||
|
||||
typedef struct _HAL_I2S_DEF_SETTING_{
|
||||
uint8_t I2SMaster; // Master or Slave mode
|
||||
uint8_t DevSts; //I2S device status
|
||||
uint8_t I2SChNum; //I2S Channel number mono or stereo
|
||||
uint8_t I2SPageNum; //I2S Page number 2~4
|
||||
uint8_t I2STRxAct; //I2S tx rx act, tx only or rx only or tx+rx
|
||||
uint8_t I2SWordLen; //I2S Word length 16bit or 24bit
|
||||
uint16_t I2SPageSize; //I2S Page size 1~4096 word
|
||||
|
||||
uint16_t I2SRate; //I2S sample rate 8k ~ 96khz
|
||||
|
||||
uint32_t I2STxIntrMSK; /*I2S Tx Interrupt Mask*/
|
||||
uint32_t I2SRxIntrMSK; /*I2S Rx Interrupt Mask*/
|
||||
}HAL_I2S_DEF_SETTING, *PHAL_I2S_DEF_SETTING;
|
||||
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
HAL_Status
|
||||
RtkI2SLoadDefault(IN void *Adapter, IN void *Setting);
|
||||
|
||||
HAL_Status
|
||||
RtkI2SInit(IN void *Data);
|
||||
|
||||
HAL_Status
|
||||
RtkI2SDeInit(IN void *Data);
|
||||
|
||||
HAL_Status
|
||||
RtkI2SEnable(IN void *Data);
|
||||
|
||||
HAL_Status
|
||||
RtkI2SDisable(IN void *Data);
|
||||
|
||||
extern HAL_Status
|
||||
HalI2SInit( IN void *Data);
|
||||
|
||||
extern void
|
||||
HalI2SDeInit( IN void *Data);
|
||||
|
||||
extern HAL_Status
|
||||
HalI2SDisable( IN void *Data);
|
||||
|
||||
extern HAL_Status
|
||||
HalI2SEnable( IN void *Data);
|
||||
|
||||
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
|
||||
void I2S0ISRHandle(void *Data);
|
||||
void I2S1ISRHandle(void *Data);
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
void HalI2SOpInit(
|
||||
IN void *Data
|
||||
);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _HAL_IRQN_H_
|
||||
#define _HAL_IRQN_H_
|
||||
|
||||
#define PERIPHERAL_IRQ_BASE_NUM 64
|
||||
|
||||
typedef enum _IRQn_Type_ {
|
||||
#if 0
|
||||
/****** Cortex-M3 Processor Exceptions Numbers ********/
|
||||
NON_MASKABLE_INT_IRQ = -14,
|
||||
HARD_FAULT_IRQ = -13,
|
||||
MEM_MANAGE_FAULT_IRQ = -12,
|
||||
BUS_FAULT_IRQ = -11,
|
||||
USAGE_FAULT_IRQ = -10,
|
||||
SVCALL_IRQ = -5,
|
||||
DEBUG_MONITOR_IRQ = -4,
|
||||
PENDSVC_IRQ = -2,
|
||||
SYSTICK_IRQ = -1,
|
||||
#else
|
||||
/****** Cortex-M3 Processor Exceptions Numbers ********/
|
||||
NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable Interrupt */
|
||||
HardFault_IRQn = -13, /*!< 3 Hard Fault, all classes of Fault */
|
||||
MemoryManagement_IRQn = -12, /*!< 4 Cortex-M3 Memory Management Interrupt */
|
||||
BusFault_IRQn = -11, /*!< 5 Cortex-M3 Bus Fault Interrupt */
|
||||
UsageFault_IRQn = -10, /*!< 6 Cortex-M3 Usage Fault Interrupt */
|
||||
SVCall_IRQn = -5, /*!< 11 Cortex-M3 SV Call Interrupt */
|
||||
DebugMonitor_IRQn = -4, /*!< 12 Cortex-M3 Debug Monitor Interrupt */
|
||||
PendSV_IRQn = -2, /*!< 14 Cortex-M3 Pend SV Interrupt */
|
||||
SysTick_IRQn = -1, /*!< 15 Cortex-M3 System Tick Interrupt */
|
||||
#endif
|
||||
/****** RTL8195A Specific Interrupt Numbers ************/
|
||||
SYSTEM_ON_IRQ = 0,
|
||||
WDG_IRQ = 1,
|
||||
TIMER0_IRQ = 2,
|
||||
TIMER1_IRQ = 3,
|
||||
I2C3_IRQ = 4,
|
||||
TIMER2_7_IRQ = 5,
|
||||
SPI0_IRQ = 6,
|
||||
GPIO_IRQ = 7,
|
||||
UART0_IRQ = 8,
|
||||
SPI_FLASH_IRQ = 9,
|
||||
USB_OTG_IRQ = 10,
|
||||
SDIO_HOST_IRQ = 11,
|
||||
SDIO_DEVICE_IRQ = 12,
|
||||
I2S0_PCM0_IRQ = 13,
|
||||
I2S1_PCM1_IRQ = 14,
|
||||
WL_DMA_IRQ = 15,
|
||||
WL_PROTOCOL_IRQ = 16,
|
||||
CRYPTO_IRQ = 17,
|
||||
GMAC_IRQ = 18,
|
||||
PERIPHERAL_IRQ = 19,
|
||||
GDMA0_CHANNEL0_IRQ = 20,
|
||||
GDMA0_CHANNEL1_IRQ = 21,
|
||||
GDMA0_CHANNEL2_IRQ = 22,
|
||||
GDMA0_CHANNEL3_IRQ = 23,
|
||||
GDMA0_CHANNEL4_IRQ = 24,
|
||||
GDMA0_CHANNEL5_IRQ = 25,
|
||||
GDMA1_CHANNEL0_IRQ = 26,
|
||||
GDMA1_CHANNEL1_IRQ = 27,
|
||||
GDMA1_CHANNEL2_IRQ = 28,
|
||||
GDMA1_CHANNEL3_IRQ = 29,
|
||||
GDMA1_CHANNEL4_IRQ = 30,
|
||||
GDMA1_CHANNEL5_IRQ = 31,
|
||||
|
||||
/****** RTL8195A Peripheral Interrupt Numbers ************/
|
||||
I2C0_IRQ = 64,// 0 + 64,
|
||||
I2C1_IRQ = 65,// 1 + 64,
|
||||
I2C2_IRQ = 66,// 2 + 64,
|
||||
SPI1_IRQ = 72,// 8 + 64,
|
||||
SPI2_IRQ = 73,// 9 + 64,
|
||||
UART1_IRQ = 80,// 16 + 64,
|
||||
UART2_IRQ = 81,// 17 + 64,
|
||||
UART_LOG_IRQ = 88,// 24 + 64,
|
||||
ADC_IRQ = 89,// 25 + 64,
|
||||
DAC0_IRQ = 91,// 27 + 64,
|
||||
DAC1_IRQ = 92,// 28 + 64,
|
||||
//RXI300_IRQ = 93// 29 + 64
|
||||
LP_EXTENSION_IRQ = 93,// 29+64
|
||||
|
||||
PTA_TRX_IRQ = 95,// 31+64
|
||||
RXI300_IRQ = 96,// 0+32 + 64
|
||||
NFC_IRQ = 97 // 1+32+64
|
||||
} IRQn_Type, *PIRQn_Type;
|
||||
|
||||
|
||||
typedef void (*HAL_VECTOR_FUN) (void);
|
||||
|
||||
typedef enum _VECTOR_TABLE_TYPE_{
|
||||
DEDECATED_VECTRO_TABLE,
|
||||
PERIPHERAL_VECTOR_TABLE
|
||||
}VECTOR_TABLE_TYPE, *PVECTOR_TABLE_TYPE;
|
||||
|
||||
|
||||
typedef void (*IRQ_FUN)(void *Data);
|
||||
|
||||
typedef struct _IRQ_HANDLE_ {
|
||||
IRQ_FUN IrqFun;
|
||||
IRQn_Type IrqNum;
|
||||
uint32_t Data;
|
||||
uint32_t Priority;
|
||||
}IRQ_HANDLE, *PIRQ_HANDLE;
|
||||
|
||||
|
||||
#endif //_HAL_IRQN_H_
|
||||
|
|
@ -0,0 +1,442 @@
|
|||
/*
|
||||
* hal_log_uart.c
|
||||
*
|
||||
* Created on: 08/10/2016
|
||||
* Author: pvvx
|
||||
*/
|
||||
#include "rtl8195a.h"
|
||||
|
||||
#ifdef CONFIG_LOG_UART_EN
|
||||
|
||||
#include "hal_log_uart.h"
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
/*
|
||||
void HalLogUartIrqHandle(void * Data);
|
||||
void HalLogUartSetBaudRate(HAL_LOG_UART_ADAPTER *pUartAdapter);
|
||||
void HalLogUartSetLineCtrl(HAL_LOG_UART_ADAPTER *pUartAdapter);
|
||||
void HalLogUartSetIntEn(HAL_LOG_UART_ADAPTER *pUartAdapter);
|
||||
uint32_t HalLogUartInitSetting(HAL_LOG_UART_ADAPTER *pUartAdapter);
|
||||
uint32_t HalLogUartRecv(HAL_LOG_UART_ADAPTER *pUartAdapter,
|
||||
uint8_t *pRxData, uint32_t Length, uint32_t TimeoutMS);
|
||||
uint32_t HalLogUartSend(HAL_LOG_UART_ADAPTER *pUartAdapter,
|
||||
uint8_t *pTxData, uint32_t Length, uint32_t TimeoutMS);
|
||||
HAL_Status HalLogUartIntSend(HAL_LOG_UART_ADAPTER *pUartAdapter,
|
||||
uint8_t *pTxData, uint32_t Length);
|
||||
HAL_Status HalLogUartIntRecv(HAL_LOG_UART_ADAPTER *pUartAdapter,
|
||||
uint8_t *pRxData, uint32_t Length);
|
||||
void HalLogUartAbortIntSend(HAL_LOG_UART_ADAPTER *pUartAdapter);
|
||||
void HalLogUartAbortIntRecv(HAL_LOG_UART_ADAPTER *pUartAdapter);
|
||||
HAL_Status HalLogUartRstFIFO(HAL_LOG_UART_ADAPTER *pUartAdapter, uint8_t RstCtrl);
|
||||
void HalLogUartEnable(HAL_LOG_UART_ADAPTER *pUartAdapter);
|
||||
void HalLogUartDisable(HAL_LOG_UART_ADAPTER *pUartAdapter);
|
||||
*/
|
||||
extern void UartLogIrqHandleRam(void * Data);
|
||||
// extern DiagPrintf();
|
||||
// extern HalGetCpuClk(void);
|
||||
// extern VectorIrqUnRegisterRtl8195A();
|
||||
// extern VectorIrqRegisterRtl8195A();
|
||||
// extern VectorIrqEnRtl8195A();
|
||||
// extern RuartIsTimeout();
|
||||
// extern HalDelayUs();
|
||||
// extern HalPinCtrlRtl8195A();
|
||||
// extern HalLogUartInit();
|
||||
//-------------------------------------------------------------------------
|
||||
// Data declarations
|
||||
// extern ConfigDebugWarn;
|
||||
// extern ConfigDebugErr;
|
||||
// extern HalTimerOp;
|
||||
// extern ConfigDebugInfo;
|
||||
// extern UartLogIrqHandleRam;
|
||||
//-------------------------------------------------------------------------
|
||||
/*
|
||||
* 16 bytes FIFO ... 16*11/38400 = 0.004583 sec
|
||||
* (0.005/5)*166666666 = 166666.666
|
||||
*/
|
||||
void HalLogUartWaitTxFifoEmpty(void) {
|
||||
int x = 16384;
|
||||
while((!(HAL_READ8(LOG_UART_REG_BASE, 0x14) & BIT6)) && x--);
|
||||
}
|
||||
|
||||
//----- HalLogUartIrqRxRdyHandle
|
||||
void HalLogUartIrqRxRdyHandle(HAL_LOG_UART_ADAPTER *pUartAdapter) {
|
||||
volatile uint8_t *pRxBuf = pUartAdapter->pRxBuf;
|
||||
if (pRxBuf != NULL) {
|
||||
while (pUartAdapter->RxCount) {
|
||||
if (!(HAL_UART_READ32(UART_INTERRUPT_EN_REG_OFF) & 1)) // v40003014
|
||||
{
|
||||
if (pUartAdapter->RxCount <= 7) {
|
||||
pUartAdapter->FIFOControl = pUartAdapter->FIFOControl
|
||||
& (~(FCR_RX_TRIG_MASK)); // & 0xFFFFFF3F;
|
||||
HAL_UART_WRITE32(UART_FIFO_CTL_REG_OFF,
|
||||
pUartAdapter->FIFOControl); // 40003008
|
||||
}
|
||||
break;
|
||||
}
|
||||
*pRxBuf++ = HAL_UART_READ32(UART_REV_BUF_OFF); // 40003000;
|
||||
--pUartAdapter->RxCount;
|
||||
}
|
||||
if (!pUartAdapter->RxCount) {
|
||||
pUartAdapter->IntEnReg = pUartAdapter->IntEnReg
|
||||
& (~(IER_ERBFI | IER_ELSI)); // & 0xFFFFFFFA;
|
||||
HAL_UART_WRITE32(UART_INTERRUPT_EN_REG_OFF, pUartAdapter->IntEnReg); // 40003004
|
||||
if (pUartAdapter->pRxBuf != pRxBuf) {
|
||||
if (pUartAdapter->RxCompCallback)
|
||||
pUartAdapter->RxCompCallback(pUartAdapter->RxCompCbPara);
|
||||
}
|
||||
if (pUartAdapter->FIFOControl & FCR_RX_TRIG_MASK) // 0xC0
|
||||
{
|
||||
pUartAdapter->FIFOControl = pUartAdapter->FIFOControl
|
||||
& (~(FCR_RX_TRIG_MASK)); // & 0xFFFFFF3F;
|
||||
HAL_UART_WRITE32(UART_FIFO_CTL_REG_OFF,
|
||||
pUartAdapter->FIFOControl); // 40003008
|
||||
}
|
||||
}
|
||||
pUartAdapter->pRxBuf = pRxBuf;
|
||||
} else
|
||||
DBG_UART_WARN("HalLogUartIrqRxDataHandle: No RX Buffer\n");
|
||||
}
|
||||
|
||||
//----- HalLogUartIrqHandle
|
||||
void HalLogUartIrqHandle(void * Data) {
|
||||
PHAL_LOG_UART_ADAPTER pUartAdapter = (PHAL_LOG_UART_ADAPTER) Data;
|
||||
uint32_t iir = HAL_UART_READ32(UART_INTERRUPT_IDEN_REG_OFF) & 0x0F; // v40003008 & 0xF;
|
||||
switch(iir) {
|
||||
case IIR_MODEM_STATUS: // Clear to send or data set ready or ring indicator or data carrier detect.
|
||||
break;
|
||||
case IIR_NO_PENDING:
|
||||
return;
|
||||
case IIR_THR_EMPTY: // TX FIFO level lower than threshold or FIFO empty
|
||||
{
|
||||
volatile uint8_t * pTxBuf = pUartAdapter->pTxBuf;
|
||||
if (pTxBuf != NULL) {
|
||||
while (pUartAdapter->TxCount) {
|
||||
if (!(HAL_UART_READ32(UART_LINE_STATUS_REG_OFF) & LSR_THRE)) { // v40003014 & 0x20 // Transmit Holding Register Empty bit(IER_PTIME=0)
|
||||
HAL_UART_WRITE32(UART_REV_BUF_OFF, *pTxBuf++);
|
||||
pUartAdapter->TxCount--; // *((_DWORD *)v1 + 4);
|
||||
}
|
||||
}
|
||||
pUartAdapter->pTxBuf = pTxBuf;
|
||||
if (!(pUartAdapter->TxCount)) {
|
||||
pUartAdapter->IntEnReg = pUartAdapter->IntEnReg & (~IER_PTIME); // & 0xFFFFFF7F
|
||||
HAL_UART_WRITE32(UART_INTERRUPT_EN_REG_OFF,
|
||||
pUartAdapter->IntEnReg); // 40003004
|
||||
if (HAL_UART_READ32(UART_LINE_STATUS_REG_OFF) & LSR_THRE) { // 40003014 & 0x20 )
|
||||
pUartAdapter->IntEnReg = pUartAdapter->IntEnReg
|
||||
& (~IER_ETBEI); // & 0xFFFFFFFD
|
||||
HAL_UART_WRITE32(UART_INTERRUPT_EN_REG_OFF,
|
||||
pUartAdapter->IntEnReg); // 40003004
|
||||
if (pUartAdapter->TxCompCallback != NULL)
|
||||
pUartAdapter->TxCompCallback(
|
||||
pUartAdapter->TxCompCbPara);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
pUartAdapter->IntEnReg = pUartAdapter->IntEnReg & (~IER_ETBEI); // & 0xFFFFFFFD
|
||||
HAL_UART_WRITE32(UART_INTERRUPT_EN_REG_OFF, pUartAdapter->IntEnReg); // 40003004
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IIR_RX_RDY: // RX data ready
|
||||
case IIR_CHAR_TIMEOUT: // timeout: Rx dara ready but no read
|
||||
HalLogUartIrqRxRdyHandle(pUartAdapter); // (HAL_LOG_UART_ADAPTER *)
|
||||
break;
|
||||
case IIR_RX_LINE_STATUS: // Overrun/parity/framing errors or break interrupt
|
||||
pUartAdapter->LineStatus = HAL_UART_READ32(UART_LINE_STATUS_REG_OFF); // *((_BYTE *)v1 + 15) = v40003014; // LineStatusCallback
|
||||
if (pUartAdapter->LineStatusCallback != NULL)
|
||||
pUartAdapter->LineStatusCallback(pUartAdapter->LineStatusCbPara, pUartAdapter->LineStatus); // v3(*((_DWORD *)v1 + 17)); RxCompCallback
|
||||
break;
|
||||
case IIR_BUSY:
|
||||
break;
|
||||
default:
|
||||
DBG_UART_WARN("HalLogUartIrqHandle: UnKnown Interrupt ID!\n");
|
||||
break;
|
||||
}
|
||||
if (pUartAdapter->api_irq_handler)
|
||||
pUartAdapter->api_irq_handler(pUartAdapter->api_irq_id, iir);
|
||||
}
|
||||
|
||||
//----- HalLogUartSetBaudRate
|
||||
void HalLogUartSetBaudRate(HAL_LOG_UART_ADAPTER *pUartAdapter) {
|
||||
uint32_t clk4 = HalGetCpuClk() >> 2; // PLATFORM_CLOCK/2; // (unsigned int) HalGetCpuClk() >> 2; // div 4
|
||||
if (pUartAdapter->BaudRate == 0)
|
||||
pUartAdapter->BaudRate = DEFAULT_BAUDRATE;
|
||||
uint32_t br16 = pUartAdapter->BaudRate << 4; // * 16
|
||||
if ((br16 != 0) && (br16 <= clk4)) {
|
||||
unsigned int dll = clk4 / br16;
|
||||
if ((((10 * clk4) / br16) - (10 * dll)) > 4)
|
||||
dll++;
|
||||
HAL_UART_WRITE32(UART_LINE_CTL_REG_OFF,
|
||||
HAL_UART_READ32(UART_LINE_CTL_REG_OFF) | LCR_DLAB);
|
||||
HAL_UART_WRITE32(UART_DLL_OFF, dll);
|
||||
HAL_UART_WRITE32(UART_DLH_OFF, dll >> 8);
|
||||
HAL_UART_WRITE32(UART_LINE_CTL_REG_OFF,
|
||||
HAL_UART_READ32(UART_LINE_CTL_REG_OFF) & (~LCR_DLAB));
|
||||
} else
|
||||
DBG_UART_ERR("Cannot support Baud Sample Rate which bigger than Serial Clk!\n");
|
||||
}
|
||||
|
||||
//----- HalLogUartSetLineCtrl
|
||||
void HalLogUartSetLineCtrl(HAL_LOG_UART_ADAPTER *pUartAdapter) {
|
||||
HAL_UART_WRITE32(UART_LINE_CTL_REG_OFF,
|
||||
pUartAdapter->Stop | pUartAdapter->Parity
|
||||
| pUartAdapter->DataLength);
|
||||
}
|
||||
|
||||
//----- HalLogUartSetIntEn
|
||||
void HalLogUartSetIntEn(HAL_LOG_UART_ADAPTER *pUartAdapter) {
|
||||
HAL_UART_WRITE32(UART_INTERRUPT_EN_REG_OFF, pUartAdapter->IntEnReg);
|
||||
}
|
||||
|
||||
//----- HalLogUartInitSetting
|
||||
uint32_t HalLogUartInitSetting(HAL_LOG_UART_ADAPTER *pUartAdapter) {
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN,
|
||||
HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) & (~BIT_SOC_LOG_UART_EN)); // 40000210 &= 0xFFFFEFFF;
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN,
|
||||
HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) | BIT_SOC_LOG_UART_EN); // 40000210 |= 0x1000;
|
||||
HAL_PERI_ON_WRITE32(REG_PESOC_CLK_CTRL,
|
||||
HAL_PERI_ON_READ32(REG_PESOC_CLK_CTRL) | BIT_SOC_ACTCK_LOG_UART_EN); // 40000230 |= 0x1000;
|
||||
// HalPinCtrlRtl8195A(LOG_UART, 0, 1); ????
|
||||
uint32_t clk4 = HalGetCpuClk() >> 2; // PLATFORM_CLOCK/2; // (unsigned int) HalGetCpuClk() >> 2; // div 4
|
||||
if (pUartAdapter->BaudRate == 0)
|
||||
pUartAdapter->BaudRate = DEFAULT_BAUDRATE;
|
||||
uint32_t br16 = pUartAdapter->BaudRate << 4; // * 16
|
||||
HAL_UART_WRITE32(UART_INTERRUPT_EN_REG_OFF, 0); // 40003004 = 0;
|
||||
if (br16 <= clk4) {
|
||||
uint32_t dll = clk4 / br16;
|
||||
if ((((10 * clk4) / br16) - (10 * dll)) > 4)
|
||||
dll++;
|
||||
HAL_UART_WRITE32(UART_LINE_CTL_REG_OFF, LCR_DLAB); // 4000300C = 128;
|
||||
HAL_UART_WRITE32(UART_DLL_OFF, dll); // v40003000 =
|
||||
HAL_UART_WRITE32(UART_DLH_OFF, dll >> 8); // v40003004 =
|
||||
HAL_UART_WRITE32(UART_LINE_CTL_REG_OFF, 0);
|
||||
}
|
||||
HAL_UART_WRITE32(UART_LINE_CTL_REG_OFF,
|
||||
pUartAdapter->Parity | pUartAdapter->Stop
|
||||
| pUartAdapter->DataLength); // 4000300C =
|
||||
HAL_UART_WRITE32(UART_FIFO_CTL_REG_OFF, pUartAdapter->FIFOControl);
|
||||
HAL_UART_WRITE32(UART_INTERRUPT_EN_REG_OFF, pUartAdapter->IntEnReg);
|
||||
|
||||
pUartAdapter->IrqHandle.IrqNum = UART_LOG_IRQ;
|
||||
pUartAdapter->IrqHandle.Data = (uint32_t)pUartAdapter;
|
||||
pUartAdapter->IrqHandle.IrqFun = HalLogUartIrqHandle;
|
||||
pUartAdapter->IrqHandle.Priority = 14;
|
||||
VectorIrqUnRegisterRtl8195A(&pUartAdapter->IrqHandle);
|
||||
VectorIrqRegisterRtl8195A(&pUartAdapter->IrqHandle);
|
||||
VectorIrqEnRtl8195A(&pUartAdapter->IrqHandle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----- HalLogUartRecv
|
||||
uint32_t HalLogUartRecv(HAL_LOG_UART_ADAPTER *pUartAdapter, uint8_t *pRxData, uint32_t Length, uint32_t TimeoutMS) {
|
||||
uint32_t result, i, timecnt, timeout; // v4 , v10
|
||||
volatile uint8_t LineStatus;
|
||||
|
||||
if ((pRxData != NULL) && Length) {
|
||||
if (TimeoutMS - 1 > 0xFFFFFFFD)
|
||||
timeout = 0;
|
||||
else {
|
||||
timeout = 1000 * TimeoutMS / 0x1F;
|
||||
timecnt = HalTimerOp.HalTimerReadCount(1);
|
||||
}
|
||||
i = 0;
|
||||
while (i < Length) {
|
||||
LineStatus = HAL_UART_READ32(UART_LINE_STATUS_REG_OFF);
|
||||
if (LineStatus & LSR_DR) {
|
||||
pRxData[i++] = HAL_UART_READ32(UART_REV_BUF_OFF);
|
||||
} else if (timeout) {
|
||||
if (RuartIsTimeout(timecnt, timeout) == HAL_TIMEOUT) {
|
||||
DBG_UART_INFO("HalLogUartRecv: Rx Timeout, RxCount=%d\n",
|
||||
timecnt, timeout);
|
||||
break;
|
||||
}
|
||||
} else if (!TimeoutMS)
|
||||
break;
|
||||
}
|
||||
result = i;
|
||||
pUartAdapter->LineStatus = LineStatus;
|
||||
} else {
|
||||
DBG_UART_ERR("HalLogUartRecv: Err: pRxData=0x%x, Length=%d!\n",
|
||||
pRxData, Length);
|
||||
result = 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//----- HalLogUartSend
|
||||
uint32_t HalLogUartSend(HAL_LOG_UART_ADAPTER *pUartAdapter,
|
||||
uint8_t *pTxData, uint32_t Length, uint32_t TimeoutMS) {
|
||||
uint32_t i, result, timeout, timecnt;
|
||||
|
||||
if ((pTxData != NULL) && Length) {
|
||||
if (TimeoutMS - 1 > 0xFFFFFFFD) {
|
||||
timeout = 0;
|
||||
} else {
|
||||
timeout = 1000 * TimeoutMS / 0x1F;
|
||||
timecnt = HalTimerOp.HalTimerReadCount(1); // v4 = (*((int (__fastcall **)(_DWORD))&HalTimerOp + 2))(1);
|
||||
}
|
||||
i = 0;
|
||||
while (i < Length) {
|
||||
if (HAL_UART_READ32(UART_LINE_STATUS_REG_OFF) & LSR_THRE) { // v40003014 & 0x20 )
|
||||
HAL_UART_WRITE32(UART_REV_BUF_OFF, pTxData[i++]); // 40003000 = pTxData[i++];
|
||||
} else if (timeout) {
|
||||
if (RuartIsTimeout(timecnt, timeout) == HAL_TIMEOUT) {
|
||||
DBG_UART_INFO("HalLogUartSend: Tx Timeout, TxCount=%d\n",
|
||||
timecnt, timeout);
|
||||
break;
|
||||
}
|
||||
} else if (!TimeoutMS)
|
||||
break;
|
||||
}
|
||||
if (i == Length)
|
||||
while (!(HAL_UART_READ32(UART_LINE_STATUS_REG_OFF) & LSR_TEMT)
|
||||
&& (!timeout
|
||||
|| RuartIsTimeout(timecnt, timeout) != HAL_TIMEOUT))
|
||||
; // 40003014 & 0x40
|
||||
result = i;
|
||||
} else {
|
||||
DBG_UART_ERR("HalLogUartSend: Err: pTxData=0x%x, Length=%d!\n",
|
||||
pTxData, Length);
|
||||
result = 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//----- HalLogUartIntSend
|
||||
HAL_Status HalLogUartIntSend(HAL_LOG_UART_ADAPTER *pUartAdapter,
|
||||
uint8_t *pTxData, uint32_t Length) {
|
||||
HAL_Status result;
|
||||
if (pTxData && Length) {
|
||||
pUartAdapter->TxCount = Length;
|
||||
pUartAdapter->pTxBuf = pTxData;
|
||||
pUartAdapter->pTxStartAddr = pTxData;
|
||||
pUartAdapter->IntEnReg = pUartAdapter->IntEnReg
|
||||
| (IER_PTIME | IER_ETBEI); // | 0x82;
|
||||
HAL_UART_WRITE32(UART_INTERRUPT_EN_REG_OFF, pUartAdapter->IntEnReg); // 40003004
|
||||
result = HAL_OK; // 0;
|
||||
} else {
|
||||
DBG_UART_ERR("HalLogUartIntSend: Err: pTxData=0x%x, Length=%d!\n",
|
||||
pTxData, Length);
|
||||
result = HAL_ERR_PARA; //3;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//----- HalLogUartIntRecv
|
||||
HAL_Status HalLogUartIntRecv(HAL_LOG_UART_ADAPTER *pUartAdapter,
|
||||
uint8_t *pRxData, uint32_t Length) {
|
||||
HAL_Status result;
|
||||
|
||||
if (pRxData && Length) {
|
||||
pUartAdapter->pRxBuf = pRxData;
|
||||
pUartAdapter->pRxStartAddr = pRxData;
|
||||
pUartAdapter->RxCount = Length;
|
||||
if (Length > 8) {
|
||||
pUartAdapter->FIFOControl = pUartAdapter->FIFOControl
|
||||
| FCR_RX_TRIG_HF; // | 0x80 RCVR Trigger: FIFO 1/2 full
|
||||
HAL_UART_WRITE32(UART_FIFO_CTL_REG_OFF, pUartAdapter->FIFOControl); // 40003008
|
||||
}
|
||||
pUartAdapter->IntEnReg = pUartAdapter->IntEnReg
|
||||
| (IER_ERBFI | IER_ELSI); // | 5
|
||||
HAL_UART_WRITE32(UART_INTERRUPT_EN_REG_OFF, pUartAdapter->IntEnReg); // 40003004
|
||||
result = HAL_OK;
|
||||
} else {
|
||||
DBG_UART_ERR("HalLogUartIntRecv: Err: pRxData=0x%x, Length=%d\n",
|
||||
pRxData, Length);
|
||||
result = HAL_ERR_PARA; // 3;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//----- HalLogUartAbortIntSend
|
||||
void HalLogUartAbortIntSend(HAL_LOG_UART_ADAPTER *pUartAdapter) {
|
||||
pUartAdapter->IntEnReg = pUartAdapter->IntEnReg
|
||||
& (~(IER_PTIME | IER_ETBEI)); // & 0xFFFFFF7D
|
||||
HAL_UART_WRITE32(UART_INTERRUPT_EN_REG_OFF, pUartAdapter->IntEnReg); // 40003004
|
||||
}
|
||||
|
||||
//----- HalLogUartAbortIntRecv
|
||||
void HalLogUartAbortIntRecv(HAL_LOG_UART_ADAPTER *pUartAdapter) {
|
||||
pUartAdapter->IntEnReg = pUartAdapter->IntEnReg & (~(IER_ERBFI | IER_ELSI)); // & 0xFFFFFFFA
|
||||
HAL_UART_WRITE32(UART_INTERRUPT_EN_REG_OFF, pUartAdapter->IntEnReg); // 40003004
|
||||
while (pUartAdapter->RxCount
|
||||
&& (HAL_UART_READ32(UART_LINE_STATUS_REG_OFF) & LSR_DR)) {
|
||||
*pUartAdapter->pRxBuf++ = HAL_UART_READ32(UART_REV_BUF_OFF); // 40003000
|
||||
pUartAdapter->RxCount--;
|
||||
}
|
||||
}
|
||||
|
||||
//----- HalLogUartRstFIFO
|
||||
HAL_Status HalLogUartRstFIFO(HAL_LOG_UART_ADAPTER *pUartAdapter, uint8_t RstCtrl) {
|
||||
uint32_t RegValue = pUartAdapter->FIFOControl;
|
||||
if (RstCtrl & LOG_UART_RST_TX_FIFO)
|
||||
RegValue |= FCR_RST_TX;
|
||||
if (RstCtrl & LOG_UART_RST_RX_FIFO)
|
||||
RegValue |= FCR_RST_RX;
|
||||
HAL_UART_WRITE32(UART_FIFO_CTL_REG_OFF, RegValue); // 40003008 = RegValue;
|
||||
if (RstCtrl & LOG_UART_RST_TX_FIFO) {
|
||||
int i = 100;
|
||||
for (RegValue = HAL_UART_READ32(UART_LINE_STATUS_REG_OFF);
|
||||
!(RegValue & LSR_TEMT);
|
||||
HAL_UART_WRITE32(UART_LINE_STATUS_REG_OFF, RegValue)) {
|
||||
if (!(i--))
|
||||
break;
|
||||
HalDelayUs(100);
|
||||
}
|
||||
}
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
//----- HalLogUartEnable
|
||||
void HalLogUartEnable(HAL_LOG_UART_ADAPTER *pUartAdapter) {
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN,
|
||||
HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) | BIT_SOC_LOG_UART_EN); // 40000210 |= 0x1000u;
|
||||
HAL_PERI_ON_WRITE32(REG_PESOC_CLK_CTRL,
|
||||
HAL_PERI_ON_READ32(REG_PESOC_CLK_CTRL) | BIT_SOC_ACTCK_LOG_UART_EN); // 40000230 |= 0x1000u;
|
||||
HalPinCtrlRtl8195A(LOG_UART, 0, 1);
|
||||
}
|
||||
|
||||
//----- HalLogUartDisable
|
||||
void HalLogUartDisable(HAL_LOG_UART_ADAPTER *pUartAdapter) {
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN,
|
||||
HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) & (~BIT_SOC_LOG_UART_EN)); // 40000210 &= 0xFFFFEFFF;
|
||||
HAL_PERI_ON_WRITE32(REG_PESOC_CLK_CTRL,
|
||||
HAL_PERI_ON_READ32(REG_PESOC_CLK_CTRL) & (~BIT_SOC_ACTCK_LOG_UART_EN)); // 40000230 &= 0xFFFFEFFF;
|
||||
HalPinCtrlRtl8195A(LOG_UART, 0, 0);
|
||||
}
|
||||
|
||||
//----- HalInitLogUart
|
||||
void HalInitLogUart(void) {
|
||||
IRQ_HANDLE UartIrqHandle;
|
||||
LOG_UART_ADAPTER UartAdapter;
|
||||
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN,
|
||||
HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) & (~BIT_SOC_LOG_UART_EN)); // 40000210 &= 0xFFFFEFFF;
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN,
|
||||
HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) | BIT_SOC_LOG_UART_EN);
|
||||
HAL_PERI_ON_WRITE32(REG_PESOC_CLK_CTRL,
|
||||
HAL_PERI_ON_READ32(REG_PESOC_CLK_CTRL) | BIT_SOC_ACTCK_LOG_UART_EN); // 40000230 |= 0x1000u;
|
||||
HalPinCtrlRtl8195A(LOG_UART, 0, 1);
|
||||
UartAdapter.BaudRate = DEFAULT_BAUDRATE;
|
||||
UartAdapter.DataLength = UART_DATA_LEN_8BIT;
|
||||
UartAdapter.FIFOControl = FCR_RX_TRIG_MASK | FCR_FIFO_EN; // 0xC1;
|
||||
UartAdapter.IntEnReg = IER_ERBFI | IER_ELSI; // 5
|
||||
UartAdapter.Parity = LCR_PARITY_NONE;
|
||||
UartAdapter.Stop = LCR_STOP_1B;
|
||||
HalLogUartInit(UartAdapter);
|
||||
UartIrqHandle.IrqNum = UART_LOG_IRQ;
|
||||
UartIrqHandle.IrqFun = (IRQ_FUN) &UartLogIrqHandleRam;
|
||||
UartIrqHandle.Data = 0;
|
||||
UartIrqHandle.Priority = 0;
|
||||
VectorIrqUnRegisterRtl8195A(&UartIrqHandle);
|
||||
VectorIrqRegisterRtl8195A(&UartIrqHandle);
|
||||
}
|
||||
|
||||
//----- HalDeinitLogUart
|
||||
void HalDeinitLogUart(void) {
|
||||
HalLogUartWaitTxFifoEmpty();
|
||||
HalPinCtrlRtl8195A(LOG_UART, 0, 0);
|
||||
}
|
||||
|
||||
#endif // CONFIG_LOG_UART_EN
|
||||
|
|
@ -0,0 +1,151 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _HAL_LOG_UART_H_
|
||||
#define _HAL_LOG_UART_H_
|
||||
|
||||
#include "hal_diag.h"
|
||||
|
||||
#define LOG_UART_WAIT_FOREVER 0xffffffff
|
||||
|
||||
// Define Line Control Register Bits
|
||||
typedef enum {
|
||||
LCR_DLS_5B = 0, // Data Length: 5 bits
|
||||
LCR_DLS_6B = BIT(0), // Data Length: 6 bits
|
||||
LCR_DLS_7B = BIT(1), // Data Length: 7 bits
|
||||
LCR_DLS_8B = (BIT(1)|BIT(0)), // Data Length: 7 bits
|
||||
|
||||
LCR_STOP_1B = 0, // Number of stop bits: 1
|
||||
LCR_STOP_2B = BIT(2), // Number of stop bits: 1.5(data len=5) or 2
|
||||
|
||||
LCR_PARITY_NONE = 0, // Parity Enable: 0
|
||||
LCR_PARITY_ODD = BIT(3), // Parity Enable: 1, Even Parity: 0
|
||||
LCR_PARITY_EVEN = (BIT(4)|BIT(3)), // Parity Enable: 1, Even Parity: 1
|
||||
|
||||
LCR_BC = BIT(6), // Break Control Bit
|
||||
LCR_DLAB = BIT(7) // Divisor Latch Access Bit
|
||||
} LOG_UART_LINE_CTRL;
|
||||
|
||||
// define Log UART Interrupt Indication ID
|
||||
/*
|
||||
IIR[3:0]:
|
||||
0000 = modem status
|
||||
0001 = no interrupt pending
|
||||
0010 = THR empty
|
||||
0100 = received data available
|
||||
0110 = receiver line status
|
||||
0111 = busy detect
|
||||
1100 = character timeout
|
||||
*/
|
||||
typedef enum {
|
||||
IIR_MODEM_STATUS = 0, // Clear to send or data set ready or ring indicator or data carrier detect.
|
||||
IIR_NO_PENDING = 1,
|
||||
IIR_THR_EMPTY = 2, // TX FIFO level lower than threshold or FIFO empty
|
||||
IIR_RX_RDY = 4, // RX data ready
|
||||
IIR_RX_LINE_STATUS = 6, // Overrun/parity/framing errors or break interrupt
|
||||
IIR_BUSY = 7,
|
||||
IIR_CHAR_TIMEOUT = 12 // timeout: Rx dara ready but no read
|
||||
} LOG_UART_INT_ID;
|
||||
|
||||
// Define Interrupt Enable Bit
|
||||
typedef enum {
|
||||
IER_ERBFI = BIT(0), // Enable Received Data Available Interrupt
|
||||
IER_ETBEI = BIT(1), // Enable Transmit Holding Register Empty Interrupt
|
||||
IER_ELSI = BIT(2), // Enable Receiver Line Status Interrupt
|
||||
IER_EDSSI = BIT(3), // Enable Modem Status Interrupt
|
||||
IER_PTIME = BIT(7) // Programmable THRE Interrupt Mode Enable
|
||||
} LOG_UART_INT_EN;
|
||||
|
||||
// Define Line Status Bit
|
||||
typedef enum {
|
||||
LSR_DR = BIT(0), // Data Ready bit
|
||||
LSR_OE = BIT(1), // Overrun error bit
|
||||
LSR_PE = BIT(2), // Parity Error bit
|
||||
LSR_FE = BIT(3), // Framing Error bit
|
||||
LSR_BI = BIT(4), // Break Interrupt bit
|
||||
LSR_THRE = BIT(5), // Transmit Holding Register Empty bit(IER_PTIME=0)
|
||||
LSR_FIFOF = BIT(5), // Transmit FIFO Full bit(IER_PTIME=1)
|
||||
LSR_TEMT = BIT(6), // Transmitter Empty bit
|
||||
LSR_RFE = BIT(7) // Receiver FIFO Error bit
|
||||
} LOG_UART_LINE_STATUS;
|
||||
|
||||
enum {
|
||||
LOG_UART_RST_TX_FIFO = 0x01,
|
||||
LOG_UART_RST_RX_FIFO = 0x02
|
||||
};
|
||||
|
||||
#define LOG_UART_TX_FIFO_DEPTH 16
|
||||
#define LOG_UART_RX_FIFO_DEPTH 16
|
||||
|
||||
// Define FIFO Control Register Bits
|
||||
typedef enum {
|
||||
FCR_FIFO_EN = BIT(0), // FIFO Enable.
|
||||
FCR_RST_RX = BIT(1), // RCVR FIFO Reset, self clear
|
||||
FCR_RST_TX = BIT(2), // XMIT FIFO Reset, self clear
|
||||
FCR_TX_TRIG_EMP = 0, // TX Empty Trigger: FIFO empty
|
||||
FCR_TX_TRIG_2CH = BIT(4), // TX Empty Trigger: 2 characters in the FIFO
|
||||
FCR_TX_TRIG_QF = BIT(5), // TX Empty Trigger: FIFO 1/4 full
|
||||
FCR_TX_TRIG_HF = (BIT(5)|BIT(4)), // TX Empty Trigger: FIFO 1/2 full
|
||||
FCR_TX_TRIG_MASK = (BIT(5)|BIT(4)), // TX Empty Trigger Bit Mask
|
||||
FCR_RX_TRIG_1CH = 0, // RCVR Trigger: 1 character in the FIFO
|
||||
FCR_RX_TRIG_QF = BIT(6), // RCVR Trigger: FIFO 1/4 full
|
||||
FCR_RX_TRIG_HF = BIT(7), // RCVR Trigger: FIFO 1/2 full
|
||||
FCR_RX_TRIG_AF = (BIT(7)|BIT(6)), // RCVR Trigger: FIFO 2 less than full
|
||||
FCR_RX_TRIG_MASK = (BIT(7)|BIT(6)) // RCVR Trigger bits Mask
|
||||
} LOG_UART_FIFO_CTRL;
|
||||
|
||||
typedef struct _HAL_LOG_UART_ADAPTER_ {
|
||||
uint32_t BaudRate; //00
|
||||
uint32_t FIFOControl; //+04
|
||||
uint32_t IntEnReg; //+08
|
||||
uint8_t Parity; //+0c
|
||||
uint8_t Stop; //+0d
|
||||
uint8_t DataLength; //+0e
|
||||
|
||||
uint8_t LineStatus; //+0f
|
||||
volatile uint32_t TxCount; //+10 how many byte to TX
|
||||
volatile uint32_t RxCount; //+14 how many bytes to RX
|
||||
volatile uint8_t *pTxBuf; //+18
|
||||
volatile uint8_t *pRxBuf; //+1c
|
||||
uint8_t *pTxStartAddr; //+20
|
||||
uint8_t *pRxStartAddr; //+24
|
||||
|
||||
IRQ_HANDLE IrqHandle; //+28
|
||||
void (*LineStatusCallback)(void *para, uint8_t status); //+38 User Line Status interrupt callback
|
||||
void (*TxCompCallback)(void *para); //+3c User Tx complete callback
|
||||
void (*RxCompCallback)(void *para); //+40 User Rx complete callback
|
||||
void *LineStatusCbPara; //+44 the argument for LineStatusCallback
|
||||
void *TxCompCbPara; //+48 the argument for TxCompCallback
|
||||
void *RxCompCbPara; //+4c the argument for RxCompCallback
|
||||
|
||||
void (*api_irq_handler)(uint32_t id, LOG_UART_INT_ID event); //+0x50
|
||||
uint32_t api_irq_id; //+0x54
|
||||
}HAL_LOG_UART_ADAPTER, *PHAL_LOG_UART_ADAPTER;
|
||||
|
||||
void HalLogUartIrqHandle(void * Data);
|
||||
void HalLogUartSetBaudRate(HAL_LOG_UART_ADAPTER *pUartAdapter);
|
||||
void HalLogUartSetLineCtrl(HAL_LOG_UART_ADAPTER *pUartAdapter);
|
||||
void HalLogUartSetIntEn(HAL_LOG_UART_ADAPTER *pUartAdapter);
|
||||
uint32_t HalLogUartInitSetting(HAL_LOG_UART_ADAPTER *pUartAdapter);
|
||||
uint32_t HalLogUartRecv(HAL_LOG_UART_ADAPTER *pUartAdapter,
|
||||
uint8_t *pRxData, uint32_t Length, uint32_t TimeoutMS);
|
||||
uint32_t HalLogUartSend(HAL_LOG_UART_ADAPTER *pUartAdapter,
|
||||
uint8_t *pTxData, uint32_t Length, uint32_t TimeoutMS);
|
||||
HAL_Status HalLogUartIntSend(HAL_LOG_UART_ADAPTER *pUartAdapter,
|
||||
uint8_t *pTxData, uint32_t Length);
|
||||
HAL_Status HalLogUartIntRecv(HAL_LOG_UART_ADAPTER *pUartAdapter,
|
||||
uint8_t *pRxData, uint32_t Length);
|
||||
void HalLogUartAbortIntSend(HAL_LOG_UART_ADAPTER *pUartAdapter);
|
||||
void HalLogUartAbortIntRecv(HAL_LOG_UART_ADAPTER *pUartAdapter);
|
||||
HAL_Status HalLogUartRstFIFO(HAL_LOG_UART_ADAPTER *pUartAdapter, uint8_t RstCtrl);
|
||||
void HalLogUartEnable(HAL_LOG_UART_ADAPTER *pUartAdapter);
|
||||
void HalLogUartDisable(HAL_LOG_UART_ADAPTER *pUartAdapter);
|
||||
void HalLogUartWaitTxFifoEmpty(void);
|
||||
|
||||
#endif
|
||||
134
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_mii.c
Normal file
134
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_mii.c
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#include "rtl8195a.h"
|
||||
|
||||
#ifdef CONFIG_MII_EN
|
||||
|
||||
#include "hal_mii.h"
|
||||
|
||||
HAL_ETHER_ADAPTER HalEtherAdp;
|
||||
|
||||
|
||||
|
||||
int32_t
|
||||
HalMiiInit(
|
||||
IN void
|
||||
)
|
||||
{
|
||||
if (FunctionChk(MII, S0) == _FALSE)
|
||||
return HAL_ERR_UNKNOWN;
|
||||
else
|
||||
return HalMiiInitRtl8195a();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
HalMiiDeInit(
|
||||
IN void
|
||||
)
|
||||
{
|
||||
HalMiiDeInitRtl8195a();
|
||||
}
|
||||
|
||||
|
||||
int32_t
|
||||
HalMiiWriteData(
|
||||
IN const char *Data,
|
||||
IN uint32_t Size
|
||||
)
|
||||
{
|
||||
return HalMiiWriteDataRtl8195a(Data, Size);
|
||||
}
|
||||
|
||||
|
||||
uint32_t
|
||||
HalMiiSendPacket(
|
||||
IN void
|
||||
)
|
||||
{
|
||||
return HalMiiSendPacketRtl8195a();
|
||||
}
|
||||
|
||||
|
||||
uint32_t
|
||||
HalMiiReceivePacket(
|
||||
IN void
|
||||
)
|
||||
{
|
||||
return HalMiiReceivePacketRtl8195a();
|
||||
}
|
||||
|
||||
|
||||
uint32_t
|
||||
HalMiiReadData(
|
||||
IN uint8_t *Data,
|
||||
IN uint32_t Size
|
||||
)
|
||||
{
|
||||
return HalMiiReadDataRtl8195a(Data, Size);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
HalMiiGetMacAddress(
|
||||
IN uint8_t *Addr
|
||||
)
|
||||
{
|
||||
HalMiiGetMacAddressRtl8195a(Addr);
|
||||
}
|
||||
|
||||
|
||||
uint32_t
|
||||
HalMiiGetLinkStatus(
|
||||
IN void
|
||||
)
|
||||
{
|
||||
return HalMiiGetLinkStatusRtl8195a();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
HalMiiForceLink(
|
||||
IN int32_t Speed,
|
||||
IN int32_t Duplex
|
||||
)
|
||||
{
|
||||
HalMiiForceLinkRtl8195a(Speed, Duplex);
|
||||
}
|
||||
|
||||
|
||||
#ifdef CONFIG_MII_VERIFY
|
||||
void
|
||||
HalMiiOpInit(
|
||||
IN void *Data
|
||||
)
|
||||
{
|
||||
PHAL_MII_OP pHalMiiOp = (PHAL_MII_OP) Data;
|
||||
|
||||
|
||||
pHalMiiOp->HalMiiGmacInit = HalMiiGmacInitRtl8195a;
|
||||
pHalMiiOp->HalMiiGmacReset = HalMiiGmacResetRtl8195a;
|
||||
pHalMiiOp->HalMiiGmacEnablePhyMode = HalMiiGmacEnablePhyModeRtl8195a;
|
||||
pHalMiiOp->HalMiiGmacXmit = HalMiiGmacXmitRtl8195a;
|
||||
pHalMiiOp->HalMiiGmacCleanTxRing = HalMiiGmacCleanTxRingRtl8195a;
|
||||
pHalMiiOp->HalMiiGmacFillTxInfo = HalMiiGmacFillTxInfoRtl8195a;
|
||||
pHalMiiOp->HalMiiGmacFillRxInfo = HalMiiGmacFillRxInfoRtl8195a;
|
||||
pHalMiiOp->HalMiiGmacTx = HalMiiGmacTxRtl8195a;
|
||||
pHalMiiOp->HalMiiGmacRx = HalMiiGmacRxRtl8195a;
|
||||
pHalMiiOp->HalMiiGmacSetDefaultEthIoCmd = HalMiiGmacSetDefaultEthIoCmdRtl8195a;
|
||||
pHalMiiOp->HalMiiGmacInitIrq = HalMiiGmacInitIrqRtl8195a;
|
||||
pHalMiiOp->HalMiiGmacGetInterruptStatus = HalMiiGmacGetInterruptStatusRtl8195a;
|
||||
pHalMiiOp->HalMiiGmacClearInterruptStatus = HalMiiGmacClearInterruptStatusRtl8195a;
|
||||
}
|
||||
#endif // #ifdef CONFIG_MII_VERIFY
|
||||
|
||||
#endif // #ifdef CONFIG_MII_EN
|
||||
|
||||
|
||||
191
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_mii.h
Normal file
191
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_mii.h
Normal file
|
|
@ -0,0 +1,191 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _HAL_MII_H_
|
||||
#define _HAL_MII_H_
|
||||
|
||||
#include "rtl8195a_mii.h"
|
||||
|
||||
|
||||
/**
|
||||
* LOG Configurations
|
||||
*/
|
||||
|
||||
#define NOLOG
|
||||
|
||||
#define LOG_TAG "NoTag"
|
||||
#define LOG_INFO_HEADER "I"
|
||||
#define LOG_DEBUG_HEADER "D"
|
||||
#define LOG_ERROR_HEADER "E"
|
||||
#define LOG_TEST_HEADER "T"
|
||||
|
||||
#define IDENT_TWO_SPACE " "
|
||||
#define IDENT_FOUR_SPACE " "
|
||||
|
||||
#define LOG_INFO(...) do {\
|
||||
DiagPrintf("\r"LOG_INFO_HEADER"/"LOG_TAG": " __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define LOG_DEBUG(...) do {\
|
||||
DiagPrintf("\r"LOG_DEBUG_HEADER"/"LOG_TAG": " __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define LOG_ERROR(...) do {\
|
||||
DiagPrintf("\r"LOG_ERROR_HEADER"/"LOG_TAG": " __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#ifdef NOLOG
|
||||
#define LOGI
|
||||
#define LOGD
|
||||
#define LOGE
|
||||
#define LOGI2
|
||||
#define LOGD2
|
||||
#define LOGE2
|
||||
#define LOGI4
|
||||
#define LOGD4
|
||||
#define LOGE4
|
||||
#else
|
||||
#define LOGI LOG_INFO
|
||||
#define LOGD LOG_DEBUG
|
||||
#define LOGE LOG_ERROR
|
||||
#define LOGI2(...) LOG_INFO(IDENT_TWO_SPACE __VA_ARGS__)
|
||||
#define LOGD2(...) LOG_DEBUG(IDENT_TWO_SPACE __VA_ARGS__)
|
||||
#define LOGE2(...) LOG_ERROR(IDENT_TWO_SPACE __VA_ARGS__)
|
||||
#define LOGI4(...) LOG_INFO(IDENT_FOUR_SPACE __VA_ARGS__)
|
||||
#define LOGD4(...) LOG_DEBUG(IDENT_FOUR_SPACE __VA_ARGS__)
|
||||
#define LOGE4(...) LOG_ERROR(IDENT_FOUR_SPACE __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#define ANSI_COLOR_GREEN "\x1b[32m"
|
||||
#define ANSI_COLOR_CYAN "\x1b[36m"
|
||||
#define ANSI_COLOR_YELLOW "\x1b[33m"
|
||||
#define ANSI_COLOR_MAGENTA "\x1b[35m"
|
||||
#define ANSI_COLOR_RED "\x1b[31m"
|
||||
#define ANSI_COLOR_BLUE "\x1b[34m"
|
||||
#define ANSI_COLOR_RESET "\x1b[0m"
|
||||
|
||||
#define DBG_ENTRANCE LOGI(ANSI_COLOR_GREEN "=> %s() <%s>\n" ANSI_COLOR_RESET, \
|
||||
__func__, __FILE__)
|
||||
|
||||
|
||||
// GMAC MII Configurations
|
||||
#ifdef LOG_TAG
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "MII"
|
||||
#endif
|
||||
|
||||
|
||||
typedef enum {
|
||||
ETH_TXDONE,
|
||||
ETH_RXDONE,
|
||||
ETH_LINKUP,
|
||||
ETH_LINKDOWN
|
||||
}EthernetEventType;
|
||||
|
||||
typedef struct _HAL_ETHER_ADAPTER_{
|
||||
IRQ_HANDLE IrqHandle;
|
||||
uint32_t InterruptMask;
|
||||
uint8_t tx_desc_num;
|
||||
uint8_t rx_desc_num;
|
||||
volatile uint8_t *TxDescAddr;
|
||||
volatile uint8_t *RxDescAddr;
|
||||
volatile uint8_t *pTxPktBuf;
|
||||
volatile uint8_t *pRxPktBuf;
|
||||
void (*CallBack)(uint32_t Event, uint32_t Data);
|
||||
}HAL_ETHER_ADAPTER, *PHAL_ETHER_ADAPTER;
|
||||
|
||||
|
||||
|
||||
extern int32_t
|
||||
HalMiiInit(
|
||||
IN void
|
||||
);
|
||||
|
||||
extern void
|
||||
HalMiiDeInit(
|
||||
IN void
|
||||
);
|
||||
|
||||
extern int32_t
|
||||
HalMiiWriteData(
|
||||
IN const char *Data,
|
||||
IN uint32_t Size
|
||||
);
|
||||
|
||||
extern uint32_t
|
||||
HalMiiSendPacket(
|
||||
IN void
|
||||
);
|
||||
|
||||
extern uint32_t
|
||||
HalMiiReceivePacket(
|
||||
IN void
|
||||
);
|
||||
|
||||
extern uint32_t
|
||||
HalMiiReadData(
|
||||
IN uint8_t *Data,
|
||||
IN uint32_t Size
|
||||
);
|
||||
|
||||
extern void
|
||||
HalMiiGetMacAddress(
|
||||
IN uint8_t *Addr
|
||||
);
|
||||
|
||||
extern uint32_t
|
||||
HalMiiGetLinkStatus(
|
||||
IN void
|
||||
);
|
||||
|
||||
extern void
|
||||
HalMiiForceLink(
|
||||
IN int32_t Speed,
|
||||
IN int32_t Duplex
|
||||
);
|
||||
|
||||
|
||||
#ifdef CONFIG_MII_VERIFY
|
||||
|
||||
typedef struct _HAL_MII_ADAPTER_ {
|
||||
uint32_t InterruptMask;
|
||||
PPHY_MODE_INFO pPhyModeInfo;
|
||||
}HAL_MII_ADAPTER, *PHAL_MII_ADAPTER;
|
||||
|
||||
typedef struct _HAL_MII_OP_ {
|
||||
BOOL (*HalMiiGmacInit)(void *Data);
|
||||
BOOL (*HalMiiGmacReset)(void *Data);
|
||||
BOOL (*HalMiiGmacEnablePhyMode)(void *Data);
|
||||
uint32_t (*HalMiiGmacXmit)(void *Data);
|
||||
void (*HalMiiGmacCleanTxRing)(void *Data);
|
||||
void (*HalMiiGmacFillTxInfo)(void *Data);
|
||||
void (*HalMiiGmacFillRxInfo)(void *Data);
|
||||
void (*HalMiiGmacTx)(void *Data);
|
||||
void (*HalMiiGmacRx)(void *Data);
|
||||
void (*HalMiiGmacSetDefaultEthIoCmd)(void *Data);
|
||||
void (*HalMiiGmacInitIrq)(void *Data);
|
||||
uint32_t (*HalMiiGmacGetInterruptStatus)(void);
|
||||
void (*HalMiiGmacClearInterruptStatus)(uint32_t IsrStatus);
|
||||
}HAL_MII_OP, *PHAL_MII_OP;
|
||||
|
||||
void HalMiiOpInit(IN void *Data);
|
||||
|
||||
typedef struct _MII_ADAPTER_ {
|
||||
PHAL_MII_OP pHalMiiOp;
|
||||
PHAL_MII_ADAPTER pHalMiiAdapter;
|
||||
PTX_INFO pTx_Info;
|
||||
PRX_INFO pRx_Info;
|
||||
void* TxBuffer;
|
||||
void* RxBuffer;
|
||||
}MII_ADAPTER, *PMII_ADAPTER;
|
||||
|
||||
#endif // #ifdef CONFIG_MII_VERIFY
|
||||
|
||||
#endif // #ifndef _HAL_MII_H_
|
||||
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* hal_misc.c
|
||||
*
|
||||
* Created on: 08/10/2016
|
||||
* Author: pvvx
|
||||
*/
|
||||
#include "rtl8195a.h"
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
/*
|
||||
void HalReInitPlatformTimer(void);
|
||||
void HalSetResetCause(IN HAL_RESET_REASON reason);
|
||||
HAL_RESET_REASON HalGetResetCause(void);
|
||||
*/
|
||||
// void HalTimerOpInit_Patch(IN void *Data); // in hal_timer.h
|
||||
//-------------------------------------------------------------------------
|
||||
// Data declarations
|
||||
// extern HAL_TIMER_OP HalTimerOp; // This variable declared in ROM code (in hal_timer.h )
|
||||
|
||||
|
||||
//----- HalReInitPlatformTimer
|
||||
void HalReInitPlatformTimer(void)
|
||||
{
|
||||
TIMER_ADAPTER TimerAdapter;
|
||||
HAL_PERI_ON_WRITE32(REG_OSC32K_CTRL, HAL_PERI_ON_READ32(REG_OSC32K_CTRL) | BIT_32K_POW_CKGEN_EN); // 40000270 |= 1
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN, HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) | BIT_SOC_GTIMER_EN); // 40000210 |= 0x10000
|
||||
HAL_PERI_ON_WRITE32(REG_PESOC_CLK_CTRL, HAL_PERI_ON_READ32(REG_PESOC_CLK_CTRL) | BIT_SOC_ACTCK_TIMER_EN); // 40000230 |= 0x4000
|
||||
HAL_PERI_ON_WRITE32(REG_PESOC_CLK_CTRL, HAL_PERI_ON_READ32(REG_PESOC_CLK_CTRL) | BIT_SOC_SLPCK_TIMER_EN); // 40000230 |= 0x8000
|
||||
HAL_PERI_ON_WRITE32(REG_PON_ISO_CTRL, HAL_PERI_ON_READ32(REG_PON_ISO_CTRL) & (~BIT_ISO_OSC32K_EN)); // 40000204 &= 0xFFFFFFEF
|
||||
TimerAdapter.TimerIrqPriority = 0;
|
||||
TimerAdapter.TimerLoadValueUs = 0;
|
||||
TimerAdapter.TimerMode = FREE_RUN_MODE;
|
||||
TimerAdapter.IrqDis = 1;
|
||||
TimerAdapter.TimerId = 1;
|
||||
HalTimerOpInit_Patch(&HalTimerOp);
|
||||
// HAL_TIMER_OP x;
|
||||
HalTimerOp.HalTimerInit(&TimerAdapter);
|
||||
HalTimerOp.HalTimerEn(1);
|
||||
}
|
||||
|
||||
//----- HalSetResetCause
|
||||
void HalSetResetCause(HAL_RESET_REASON reason)
|
||||
{
|
||||
HAL_PERI_ON_WRITE32(REG_SYS_DSLP_TIM_CTRL, HAL_PERI_ON_READ32(REG_SYS_DSLP_TIM_CTRL) | BIT31); // 40000094 |= 0x80000000
|
||||
HAL_PERI_ON_WRITE32(REG_SYS_DSLP_TIM_CTRL, (HAL_PERI_ON_READ32(REG_SYS_DSLP_TIM_CTRL) & 0xffff0000) | 0x9700 | (reason & 0xff)); // 40000094 = (40000094 >> 16 << 16) | 0x9700 | (uint8_t)reason;
|
||||
while(HAL_PERI_ON_READ32(REG_SYS_DSLP_TIM_CTRL) & 0x8000);
|
||||
}
|
||||
|
||||
//----- HalGetResetCause
|
||||
HAL_RESET_REASON HalGetResetCause(void)
|
||||
{
|
||||
HAL_PERI_ON_WRITE32(REG_SYS_DSLP_TIM_CTRL, HAL_PERI_ON_READ32(REG_SYS_DSLP_TIM_CTRL) | BIT31); // 40000094 |= 0x80000000
|
||||
HAL_PERI_ON_WRITE32(REG_SYS_DSLP_TIM_CTRL, (HAL_PERI_ON_READ32(REG_SYS_DSLP_TIM_CTRL) & 0xFFFF00FF) | 0x8700); // 40000094 = 40000094 & 0xFFFF00FF | 0x8700
|
||||
while(HAL_PERI_ON_READ32(REG_SYS_DSLP_TIM_CTRL) & 0x8000);
|
||||
return HAL_PERI_ON_READ32(REG_SYS_DSLP_TIM_CTRL);
|
||||
}
|
||||
|
||||
uint8_t HalGetChipId(void) {
|
||||
uint8_t chip_id = CHIP_ID_8195AM;
|
||||
#if CONFIG_DEBUG_LOG > 3
|
||||
if (HALEFUSEOneByteReadROM(HAL_SYS_CTRL_READ32(REG_SYS_EFUSE_CTRL), 0xF8, &chip_id, L25EOUTVOLTAGE) != 1)
|
||||
DBG_MISC_INFO("Get Chip ID Failed\r");
|
||||
#else
|
||||
HALEFUSEOneByteReadROM(HAL_SYS_CTRL_READ32(REG_SYS_EFUSE_CTRL), 0xF8, &chip_id, L25EOUTVOLTAGE);
|
||||
#endif
|
||||
return chip_id;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _MISC_H_
|
||||
#define _MISC_H_
|
||||
|
||||
#include <basic_types.h>
|
||||
|
||||
#define CHIP_ID_8711AM 0xFF
|
||||
#define CHIP_ID_8195AM 0xFE
|
||||
#define CHIP_ID_8711AF 0xFD
|
||||
#define CHIP_ID_8710AF 0xFC
|
||||
#define CHIP_ID_8711AN 0xFB
|
||||
#define CHIP_ID_8710AM 0xFA
|
||||
|
||||
enum _HAL_RESET_REASON{
|
||||
REASON_DEFAULT_RST = 0, /**< normal startup by power on */
|
||||
REASON_WDT_RST, /**< hardware watch dog reset */
|
||||
REASON_EXCEPTION_RST, /**< exception reset, GPIO status won't change */
|
||||
REASON_SOFT_WDT_RST, /**< software watch dog reset, GPIO status won't change */
|
||||
REASON_SOFT_RESTART, /**< software restart ,system_restart , GPIO status won't change */
|
||||
REASON_DEEP_SLEEP_AWAKE, /**< wake up from deep-sleep */
|
||||
REASON_EXT_SYS_RST /**< external system reset */
|
||||
};
|
||||
typedef uint32_t HAL_RESET_REASON;
|
||||
|
||||
#ifdef CONFIG_TIMER_MODULE
|
||||
extern _LONG_CALL_ unsigned int HalDelayUs(unsigned int us);
|
||||
#endif
|
||||
|
||||
extern _LONG_CALL_ unsigned int HalGetCpuClk(void);
|
||||
extern _LONG_CALL_ unsigned char HalGetRomInfo(void);
|
||||
extern uint8_t HalGetChipId(void);
|
||||
|
||||
extern _LONG_CALL_ROM_ void *_memset( void *s, int c, SIZE_T n );
|
||||
extern _LONG_CALL_ROM_ void *_memcpy( void *s1, const void *s2, SIZE_T n );
|
||||
#if defined(CONFIG_RELEASE_BUILD_LIBRARIES) && (!defined(E_CUT_ROM_DOMAIN))
|
||||
// we built A/B/C cut ROM Lib with this wrong declaration, we need to keep the same for compatible
|
||||
extern _LONG_CALL_ROM_ int *_memcmp( const void *av, const void *bv, SIZE_T len );
|
||||
#else
|
||||
extern _LONG_CALL_ROM_ int _memcmp( const void *av, const void *bv, SIZE_T len );
|
||||
#endif
|
||||
extern _LONG_CALL_ROM_ SIZE_T _strlen(const char *s);
|
||||
extern _LONG_CALL_ROM_ int _strcmp(const char *cs, const char *ct);
|
||||
|
||||
void HalSetResetCause(IN HAL_RESET_REASON reason);
|
||||
HAL_RESET_REASON HalGetResetCause(void);
|
||||
|
||||
|
||||
#endif //_MISC_H_
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
|
||||
#include "rtl8195a.h"
|
||||
#include "hal_nfc.h"
|
||||
|
||||
#ifdef CONFIG_NFC_EN
|
||||
|
||||
void HalNFCOpInit(
|
||||
IN void *Data
|
||||
)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endif //CONFIG_NFC_EN
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _HAL_NFC_H_
|
||||
#define _HAL_NFC_H_
|
||||
|
||||
#include "rtl8195a_nfc.h"
|
||||
|
||||
|
||||
void HalNFCOpInit(
|
||||
IN void *Data
|
||||
);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
|
||||
#include "platform_autoconf.h"
|
||||
#include "hal_pcm.h"
|
||||
|
||||
#ifdef CONFIG_PCM_EN
|
||||
|
||||
void HalPcmOpInit(
|
||||
IN void *Data
|
||||
)
|
||||
{
|
||||
PHAL_PCM_OP pHalPcmOp = (PHAL_PCM_OP) Data;
|
||||
|
||||
pHalPcmOp->HalPcmOnOff = HalPcmOnOffRtl8195a;
|
||||
pHalPcmOp->HalPcmInit = HalPcmInitRtl8195a;
|
||||
pHalPcmOp->HalPcmSetting = HalPcmSettingRtl8195a;
|
||||
pHalPcmOp->HalPcmEn = HalPcmEnRtl8195a;
|
||||
pHalPcmOp->HalPcmIsrEnAndDis= HalPcmIsrEnAndDisRtl8195a;
|
||||
pHalPcmOp->HalPcmDumpReg= HalPcmDumpRegRtl8195a;
|
||||
pHalPcmOp->HalPcm= HalPcmRtl8195a;
|
||||
}
|
||||
|
||||
#endif //CONFIG_PCM_EN
|
||||
104
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_pcm.h
Normal file
104
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_pcm.h
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _HAL_PCM_H_
|
||||
#define _HAL_PCM_H_
|
||||
|
||||
#include "rtl8195a_pcm.h"
|
||||
/*
|
||||
typedef struct _GDMA_CH_LLI_ELE_ {
|
||||
uint32_t Sarx;
|
||||
uint32_t Darx;
|
||||
uint32_t Llpx;
|
||||
uint32_t CtlxLow;
|
||||
uint32_t CtlxUp;
|
||||
uint32_t Temp;
|
||||
}GDMA_CH_LLI_ELE, *PGDMA_CH_LLI_ELE;
|
||||
#if 1
|
||||
#if 0
|
||||
typedef struct _GDMA_CH_LLI_ {
|
||||
PGDMA_CH_LLI_ELE pLliEle;
|
||||
PGDMA_CH_LLI pNextLli;
|
||||
}GDMA_CH_LLI, *PGDMA_CH_LLI;
|
||||
|
||||
typedef struct _BLOCK_SIZE_LIST_ {
|
||||
uint32_t BlockSize;
|
||||
PBLOCK_SIZE_LIST pNextBlockSiz;
|
||||
}BLOCK_SIZE_LIST, *PBLOCK_SIZE_LIST;
|
||||
#else
|
||||
struct GDMA_CH_LLI {
|
||||
PGDMA_CH_LLI_ELE pLliEle;
|
||||
struct GDMA_CH_LLI *pNextLli;
|
||||
};
|
||||
|
||||
struct BLOCK_SIZE_LIST {
|
||||
uint32_t BlockSize;
|
||||
struct BLOCK_SIZE_LIST *pNextBlockSiz;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
typedef struct _HAL_GDMA_ADAPTER_ {
|
||||
uint32_t ChSar;
|
||||
uint32_t ChDar;
|
||||
GDMA_CHANNEL_NUM ChEn;
|
||||
GDMA_CTL_REG GdmaCtl;
|
||||
GDMA_CFG_REG GdmaCfg;
|
||||
uint32_t PacketLen;
|
||||
uint32_t BlockLen;
|
||||
uint32_t MuliBlockCunt;
|
||||
uint32_t MaxMuliBlock;
|
||||
struct GDMA_CH_LLI *pLlix;
|
||||
struct BLOCK_SIZE_LIST *pBlockSizeList;
|
||||
|
||||
PGDMA_CH_LLI_ELE pLli;
|
||||
uint32_t NextPlli;
|
||||
uint8_t TestItem;
|
||||
uint8_t ChNum;
|
||||
uint8_t GdmaIndex;
|
||||
uint8_t IsrCtrl:1;
|
||||
uint8_t GdmaOnOff:1;
|
||||
uint8_t Llpctrl:1;
|
||||
uint8_t Lli0:1;
|
||||
uint8_t Rsvd4to7:4;
|
||||
uint8_t GdmaIsrType;
|
||||
}HAL_GDMA_ADAPTER, *PHAL_GDMA_ADAPTER;
|
||||
|
||||
*/
|
||||
|
||||
typedef struct _HAL_PCM_ADAPTER_ {
|
||||
uint32_t Enable:1;
|
||||
PCM_CTL_REG PcmCtl;
|
||||
PCM_CHCNR03_REG PcmChCNR03;
|
||||
PCM_TSR03_REG PcmTSR03;
|
||||
PCM_BSIZE03_REG PcmBSize03;
|
||||
uint32_t abc;
|
||||
uint8_t PcmIndex;
|
||||
uint8_t PcmCh;
|
||||
}HAL_PCM_ADAPTER, *PHAL_PCM_ADAPTER;
|
||||
|
||||
|
||||
typedef struct _HAL_PCM_OP_ {
|
||||
void (*HalPcmOnOff)(void *Data);
|
||||
BOOL (*HalPcmInit)(void *Data);
|
||||
BOOL (*HalPcmSetting)(void *Data);
|
||||
BOOL (*HalPcmEn)(void *Data);
|
||||
BOOL (*HalPcmIsrEnAndDis) (void *Data);
|
||||
BOOL (*HalPcmDumpReg)(void *Data);
|
||||
BOOL (*HalPcm)(void *Data);
|
||||
}HAL_PCM_OP, *PHAL_PCM_OP;
|
||||
|
||||
|
||||
void HalPcmOpInit(
|
||||
IN void *Data
|
||||
);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,451 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _HAL_PERI_ON_H_
|
||||
#define _HAL_PERI_ON_H_
|
||||
|
||||
#define MASK_ALLON 0xFFFFFFFF
|
||||
|
||||
#define HAL_PERI_ON_READ32(addr) HAL_READ32(PERI_ON_BASE, addr)
|
||||
#define HAL_PERI_ON_WRITE32(addr, value) HAL_WRITE32(PERI_ON_BASE, addr, value)
|
||||
#define HAL_PERI_ON_READ16(addr) HAL_READ16(PERI_ON_BASE, addr)
|
||||
#define HAL_PERI_ON_WRITE16(addr, value) HAL_WRITE16(PERI_ON_BASE, addr, value)
|
||||
#define HAL_PERI_ON_READ8(addr) HAL_READ8(PERI_ON_BASE, addr)
|
||||
#define HAL_PERI_ON_WRITE8(addr, value) HAL_WRITE8(PERI_ON_BASE, addr, value)
|
||||
#define HAL_PERL_ON_FUNC_CTRL(addr,value,ctrl) \
|
||||
HAL_PERI_ON_WRITE32(addr, ((HAL_PERI_ON_READ32(addr) & (~value))|((MASK_ALLON - ctrl + 1) & value)))
|
||||
#define HAL_PERL_ON_PIN_SEL(addr,mask,value) \
|
||||
HAL_PERI_ON_WRITE32(addr, ((HAL_PERI_ON_READ32(addr) & (~mask)) | value))
|
||||
|
||||
//40 REG_SYS_REGU_CTRL0
|
||||
#define LDO25M_CTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_SYS_REGU_CTRL0, BIT_SYS_REGU_LDO25M_EN, ctrl)
|
||||
|
||||
//A0 SYS_DEBUG_CTRL
|
||||
#define DEBUG_PIN_CTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_SYS_DEBUG_CTRL, BIT_SYS_DBG_PIN_EN, ctrl)
|
||||
|
||||
//A4 SYS_PINMUX_CTRL
|
||||
#define SIC_PIN_CTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_SYS_PINMUX_CTRL, BIT_SIC_PIN_EN, ctrl)
|
||||
#define EEPROM_PIN_CTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_SYS_PINMUX_CTRL, BIT_EEPROM_PIN_EN, ctrl)
|
||||
|
||||
|
||||
//210 SOV_FUNC_EN
|
||||
#define LXBUS_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_SOC_FUNC_EN, BIT_SOC_LXBUS_EN, ctrl)
|
||||
#define FLASH_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(SPI_FLASH_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_FUNC_EN, BIT_SOC_FLASH_EN, ctrl);}
|
||||
|
||||
#define MEM_CTRL_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(SDR_SDRAM_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_FUNC_EN, BIT_SOC_MEM_CTRL_EN, ctrl);}
|
||||
|
||||
#define LOC_UART_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(LOG_UART_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_FUNC_EN, BIT_SOC_LOG_UART_EN, ctrl);}
|
||||
|
||||
#define GDMA0_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(GDMA0_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_FUNC_EN, BIT_SOC_GDMA0_EN, ctrl);}
|
||||
|
||||
#define GDMA1_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(GDMA1_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_FUNC_EN, BIT_SOC_GDMA1_EN, ctrl);}
|
||||
|
||||
#define GTIMER_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(TIMER_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_FUNC_EN, BIT_SOC_GTIMER_EN, ctrl);}
|
||||
|
||||
#define SECURITY_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(CRYPTO_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_FUNC_EN, BIT_SOC_SECURITY_ENGINE_EN, ctrl);}
|
||||
|
||||
//214 SOC_HCI_COM_FUNC_EN
|
||||
#define SDIOD_ON_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(SDIO_DEVICE_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_HCI_COM_FUNC_EN, BIT_SOC_HCI_SDIOD_ON_EN, ctrl);}
|
||||
|
||||
#define SDIOD_OFF_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(SDIO_DEVICE_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_HCI_COM_FUNC_EN, BIT_SOC_HCI_SDIOD_OFF_EN, ctrl);}
|
||||
|
||||
#define SDIOH_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(SDIO_HOST_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_HCI_COM_FUNC_EN, BIT_SOC_HCI_SDIOH_EN, ctrl);}
|
||||
|
||||
#define SDIO_ON_RST_MASK(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_SOC_HCI_COM_FUNC_EN, BIT_SOC_HCI_SDIOD_ON_RST_MUX, ctrl)
|
||||
#define OTG_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(USB_OTG_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_HCI_COM_FUNC_EN, BIT_SOC_HCI_OTG_EN, ctrl);}
|
||||
|
||||
#define OTG_RST_MASK(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_SOC_HCI_COM_FUNC_EN, BIT_SOC_HCI_OTG_RST_MUX, ctrl)
|
||||
#define MII_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(MII_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_HCI_COM_FUNC_EN, BIT_SOC_HCI_MII_EN, ctrl);}
|
||||
|
||||
#define MII_MUX_SEL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_SOC_HCI_COM_FUNC_EN, BIT_SOC_HCI_SM_SEL, ctrl)
|
||||
#define WL_MACON_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(WIFI_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_HCI_COM_FUNC_EN, BIT_SOC_HCI_WL_MACON_EN, ctrl);}
|
||||
|
||||
//218 SOC_PERI_FUNC0_EN
|
||||
#define UART0_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(UART0_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_PERI_FUNC0_EN, BIT_PERI_UART0_EN, ctrl);}
|
||||
|
||||
#define UART1_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(UART1_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_PERI_FUNC0_EN, BIT_PERI_UART1_EN, ctrl);}
|
||||
|
||||
#define UART2_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(UART2_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_PERI_FUNC0_EN, BIT_PERI_UART2_EN, ctrl);}
|
||||
|
||||
#define SPI0_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(SPI0_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_PERI_FUNC0_EN, BIT_PERI_SPI0_EN, ctrl);}
|
||||
|
||||
#define SPI1_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(SPI1_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_PERI_FUNC0_EN, BIT_PERI_SPI1_EN, ctrl);}
|
||||
|
||||
#define SPI2_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(SPI2_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_PERI_FUNC0_EN, BIT_PERI_SPI2_EN, ctrl);}
|
||||
|
||||
#define I2C0_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(I2C0_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_PERI_FUNC0_EN, BIT_PERI_I2C0_EN, ctrl);}
|
||||
|
||||
#define I2C1_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(I2C1_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_PERI_FUNC0_EN, BIT_PERI_I2C1_EN, ctrl);}
|
||||
|
||||
#define I2C2_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(I2C2_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_PERI_FUNC0_EN, BIT_PERI_I2C2_EN, ctrl);}
|
||||
|
||||
#define I2C3_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(I2C3_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_PERI_FUNC0_EN, BIT_PERI_I2C3_EN, ctrl);}
|
||||
|
||||
#define I2S0_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(I2S0_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_PERI_FUNC0_EN, BIT_PERI_I2S0_EN, ctrl);}
|
||||
|
||||
#define I2S1_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(I2S1_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_PERI_FUNC0_EN, BIT_PERI_I2S1_EN, ctrl);}
|
||||
|
||||
#define PCM0_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(PCM0_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_PERI_FUNC0_EN, BIT_PERI_PCM0_EN, ctrl);}
|
||||
|
||||
#define PCM1_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(PCM1_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_PERI_FUNC0_EN, BIT_PERI_PCM1_EN, ctrl);}
|
||||
|
||||
//21C SOC_PERI_FUNC1_EN
|
||||
#define ADC0_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(ADC_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_PERI_FUNC1_EN, BIT_PERI_ADC0_EN, ctrl);}
|
||||
|
||||
#define DAC0_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(DAC_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_PERI_FUNC1_EN, BIT_PERI_DAC0_EN, ctrl);}
|
||||
|
||||
#define DAC1_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(DAC_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_PERI_FUNC1_EN, BIT_PERI_DAC1_EN, ctrl);}
|
||||
|
||||
#define GPIO_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(GPIO_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_PERI_FUNC1_EN, BIT_PERI_GPIO_EN, ctrl);}
|
||||
|
||||
//220 SOC_PERI_BD_FUNC0_EN
|
||||
#define UART0_BD_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(UART0_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_PERI_BD_FUNC0_EN, BIT_PERI_UART0_BD_EN, ctrl);}
|
||||
|
||||
#define UART1_BD_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(UART1_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_PERI_BD_FUNC0_EN, BIT_PERI_UART1_BD_EN, ctrl);}
|
||||
|
||||
#define UART2_BD_FCTRL(ctrl) { \
|
||||
if (!ctrl) { \
|
||||
HAL_READ32(UART2_REG_BASE,0);\
|
||||
}\
|
||||
HAL_PERL_ON_FUNC_CTRL(REG_SOC_PERI_BD_FUNC0_EN, BIT_PERI_UART2_BD_EN, ctrl);}
|
||||
|
||||
//230 PESOC_CLK_CTRL
|
||||
#define ACTCK_CPU_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_CLK_CTRL, BIT_SOC_CKE_PLFM, ctrl)
|
||||
#define ACTCK_TRACE_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_CLK_CTRL, BIT_SOC_ACTCK_TRACE_EN, ctrl)
|
||||
#define SLPCK_TRACE_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_CLK_CTRL, BIT_SOC_SLPCK_TRACE_EN, ctrl)
|
||||
#define ACTCK_VENDOR_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_CLK_CTRL, BIT_SOC_ACTCK_VENDOR_REG_EN, ctrl)
|
||||
#define SLPCK_VENDOR_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_CLK_CTRL, BIT_SOC_SLPCK_VENDOR_REG_EN, ctrl)
|
||||
#define ACTCK_FLASH_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_CLK_CTRL, BIT_SOC_ACTCK_FLASH_EN, ctrl)
|
||||
#define SLPCK_FLASH_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_CLK_CTRL, BIT_SOC_SLPCK_FLASH_EN, ctrl)
|
||||
#define ACTCK_SDR_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_CLK_CTRL, BIT_SOC_ACTCK_SDR_EN, ctrl)
|
||||
#define SLPCK_SDR_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_CLK_CTRL, BIT_SOC_SLPCK_SDR_EN, ctrl)
|
||||
#define ACTCK_LOG_UART_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_CLK_CTRL, BIT_SOC_ACTCK_LOG_UART_EN, ctrl)
|
||||
#define SLPCK_LOG_UART_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_CLK_CTRL, BIT_SOC_SLPCK_LOG_UART_EN, ctrl)
|
||||
#define ACTCK_TIMER_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_CLK_CTRL, BIT_SOC_ACTCK_TIMER_EN, ctrl)
|
||||
#define SLPCK_TIMER_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_CLK_CTRL, BIT_SOC_SLPCK_TIMER_EN, ctrl)
|
||||
#define ACTCK_GDMA0_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_CLK_CTRL, BIT_SOC_ACTCK_GDMA0_EN, ctrl)
|
||||
#define SLPCK_GDMA0_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_CLK_CTRL, BIT_SOC_SLPCK_GDMA0_EN, ctrl)
|
||||
#define ACTCK_GDMA1_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_CLK_CTRL, BIT_SOC_ACTCK_GDMA1_EN, ctrl)
|
||||
#define SLPCK_GDMA1_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_CLK_CTRL, BIT_SOC_SLPCK_GDMA1_EN, ctrl)
|
||||
#define ACTCK_GPIO_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_CLK_CTRL, BIT_SOC_ACTCK_GPIO_EN, ctrl)
|
||||
#define SLPCK_GPIO_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_CLK_CTRL, BIT_SOC_SLPCK_GPIO_EN, ctrl)
|
||||
#define ACTCK_BTCMD_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_CLK_CTRL, BIT_SOC_ACTCK_BTCMD_EN, ctrl)
|
||||
#define SLPCK_BTCMD_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_CLK_CTRL, BIT_SOC_SLPCK_BTCMD_EN, ctrl)
|
||||
|
||||
//234 PESOC_PERI_CLK_CTRL0
|
||||
#define ACTCK_UART0_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_PERI_CLK_CTRL0, BIT_SOC_ACTCK_UART0_EN, ctrl)
|
||||
#define SLPCK_UART0_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_PERI_CLK_CTRL0, BIT_SOC_SLPCK_UART0_EN, ctrl)
|
||||
#define ACTCK_UART1_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_PERI_CLK_CTRL0, BIT_SOC_ACTCK_UART1_EN, ctrl)
|
||||
#define SLPCK_UART1_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_PERI_CLK_CTRL0, BIT_SOC_SLPCK_UART1_EN, ctrl)
|
||||
#define ACTCK_UART2_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_PERI_CLK_CTRL0, BIT_SOC_ACTCK_UART2_EN, ctrl)
|
||||
#define SLPCK_UART2_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_PERI_CLK_CTRL0, BIT_SOC_SLPCK_UART2_EN, ctrl)
|
||||
#define ACTCK_SPI0_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_PERI_CLK_CTRL0, BIT_SOC_ACTCK_SPI0_EN, ctrl)
|
||||
#define SLPCK_SPI0_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_PERI_CLK_CTRL0, BIT_SOC_SLPCK_SPI0_EN, ctrl)
|
||||
#define ACTCK_SPI1_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_PERI_CLK_CTRL0, BIT_SOC_ACTCK_SPI1_EN, ctrl)
|
||||
#define SLPCK_SPI1_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_PERI_CLK_CTRL0, BIT_SOC_SLPCK_SPI1_EN, ctrl)
|
||||
#define ACTCK_SPI2_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_PERI_CLK_CTRL0, BIT_SOC_ACTCK_SPI2_EN, ctrl)
|
||||
#define SLPCK_SPI2_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_PERI_CLK_CTRL0, BIT_SOC_SLPCK_SPI2_EN, ctrl)
|
||||
|
||||
//238 PESOC_PERI_CLK_CTRL1
|
||||
#define ACTCK_I2C0_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_PERI_CLK_CTRL1, BIT_SOC_ACTCK_I2C0_EN, ctrl)
|
||||
#define SLPCK_I2C0_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_PERI_CLK_CTRL1, BIT_SOC_SLPCK_I2C0_EN, ctrl)
|
||||
#define ACTCK_I2C1_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_PERI_CLK_CTRL1, BIT_SOC_ACTCK_I2C1_EN, ctrl)
|
||||
#define SLPCK_I2C1_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_PERI_CLK_CTRL1, BIT_SOC_SLPCK_I2C1_EN, ctrl)
|
||||
#define ACTCK_I2C2_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_PERI_CLK_CTRL1, BIT_SOC_ACTCK_I2C2_EN, ctrl)
|
||||
#define SLPCK_I2C2_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_PERI_CLK_CTRL1, BIT_SOC_SLPCK_I2C2_EN, ctrl)
|
||||
#define ACTCK_I2C3_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_PERI_CLK_CTRL1, BIT_SOC_ACTCK_I2C3_EN, ctrl)
|
||||
#define SLPCK_I2C3_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_PERI_CLK_CTRL1, BIT_SOC_SLPCK_I2C3_EN, ctrl)
|
||||
#define ACTCK_I2S_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_PERI_CLK_CTRL1, BIT_SOC_ACTCK_I2S_EN, ctrl)
|
||||
#define SLPCK_I2S_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_PERI_CLK_CTRL1, BIT_SOC_SLPCK_I2S_EN, ctrl)
|
||||
#define ACTCK_PCM_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_PERI_CLK_CTRL1, BIT_SOC_ACTCK_PCM_EN, ctrl)
|
||||
#define SLPCK_PCM_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_PERI_CLK_CTRL1, BIT_SOC_SLPCK_PCM_EN, ctrl)
|
||||
#define ACTCK_ADC_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_PERI_CLK_CTRL1, BIT_SOC_ACTCK_ADC_EN, ctrl)
|
||||
#define SLPCK_ADC_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_PERI_CLK_CTRL1, BIT_SOC_SLPCK_ADC_EN, ctrl)
|
||||
#define ACTCK_DAC_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_PERI_CLK_CTRL1, BIT_SOC_ACTCK_DAC_EN, ctrl)
|
||||
#define SLPCK_DAC_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_PERI_CLK_CTRL1, BIT_SOC_SLPCK_DAC_EN, ctrl)
|
||||
|
||||
//240 PESOC_HCI_CLK_CTRL0
|
||||
#define ACTCK_SDIOD_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_HCI_CLK_CTRL0, BIT_SOC_ACTCK_SDIO_DEV_EN, ctrl)
|
||||
#define SLPCK_SDIOD_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_HCI_CLK_CTRL0, BIT_SOC_SLPCK_SDIO_DEV_EN, ctrl)
|
||||
#define ACTCK_SDIOH_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_HCI_CLK_CTRL0, BIT_SOC_ACTCK_SDIO_HST_EN, ctrl)
|
||||
#define SLPCK_SDIOH_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_HCI_CLK_CTRL0, BIT_SOC_SLPCK_SDIO_HST_EN, ctrl)
|
||||
#define ACTCK_OTG_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_HCI_CLK_CTRL0, BIT_SOC_ACTCK_OTG_EN, ctrl)
|
||||
#define SLPCK_OTG_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_HCI_CLK_CTRL0, BIT_SOC_SLPCK_OTG_EN, ctrl)
|
||||
#define ACTCK_MII_MPHY_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_HCI_CLK_CTRL0, BIT_SOC_ACTCK_MII_MPHY_EN, ctrl)
|
||||
#define SLPCK_MII_MPHY_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_HCI_CLK_CTRL0, BIT_SOC_SLPCK_MII_MPHY_EN, ctrl)
|
||||
|
||||
//244 PESOC_COM_CLK_CTRL1
|
||||
#define ACTCK_WL_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_COM_CLK_CTRL1, BIT_SOC_ACTCK_WL_EN, ctrl)
|
||||
#define SLPCK_WL_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_COM_CLK_CTRL1, BIT_SOC_SLPCK_WL_EN, ctrl)
|
||||
#define ACTCK_SEC_ENG_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_COM_CLK_CTRL1, BIT_SOC_ACTCK_SECURITY_ENG_EN, ctrl)
|
||||
#define SLPCK_SEC_ENG_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_COM_CLK_CTRL1, BIT_SOC_SLPCK_SECURITY_ENG_EN, ctrl)
|
||||
#define ACTCK_NFC_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_COM_CLK_CTRL1, BIT_SOC_ACTCK_NFC_EN, ctrl)
|
||||
#define SLPCK_NFC_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_COM_CLK_CTRL1, BIT_SOC_SLPCK_NFC_EN, ctrl)
|
||||
#define NFC_CAL_CCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_COM_CLK_CTRL1, BIT_SOC_NFC_CAL_EN, ctrl)
|
||||
|
||||
//250 REG_PERI_CLK_SEL
|
||||
#define TRACE_CLK_SEL(num) HAL_PERL_ON_PIN_SEL(REG_PESOC_CLK_SEL, (BIT_MASK_PESOC_TRACE_CK_SEL << BIT_SHIFT_PESOC_TRACE_CK_SEL), BIT_PESOC_TRACE_CK_SEL(num))
|
||||
#define FLASH_CLK_SEL(num) HAL_PERL_ON_PIN_SEL(REG_PESOC_CLK_SEL, (BIT_MASK_PESOC_FLASH_CK_SEL << BIT_SHIFT_PESOC_FLASH_CK_SEL), BIT_PESOC_FLASH_CK_SEL(num))
|
||||
#define SDR_CLK_SEL(num) HAL_PERL_ON_PIN_SEL(REG_PESOC_CLK_SEL, (BIT_MASK_PESOC_SDR_CK_SEL << BIT_SHIFT_PESOC_SDR_CK_SEL), BIT_PESOC_SDR_CK_SEL(num))
|
||||
#define I2C_SCLK_SEL(num) HAL_PERL_ON_PIN_SEL(REG_PESOC_CLK_SEL, (BIT_MASK_PESOC_PERI_SCLK_SEL << BIT_SHIFT_PESOC_PERI_SCLK_SEL), BIT_PESOC_PERI_SCLK_SEL(num))
|
||||
|
||||
//270 REG_OSC32K_CTRL
|
||||
#define OSC32K_CKGEN_CTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_OSC32K_CTRL, BIT_32K_POW_CKGEN_EN, ctrl)
|
||||
|
||||
//280 REG_UART_MUX_CTRL
|
||||
#define UART0_PIN_CTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_UART_MUX_CTRL, BIT_UART0_PIN_EN, ctrl)
|
||||
#define UART0_PIN_SEL(num) HAL_PERL_ON_PIN_SEL(REG_UART_MUX_CTRL, (BIT_MASK_UART0_PIN_SEL << BIT_SHIFT_UART0_PIN_SEL), BIT_UART0_PIN_SEL(num))
|
||||
#define UART1_PIN_CTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_UART_MUX_CTRL, BIT_UART1_PIN_EN, ctrl)
|
||||
#define UART1_PIN_SEL(num) HAL_PERL_ON_PIN_SEL(REG_UART_MUX_CTRL, (BIT_MASK_UART1_PIN_SEL << BIT_SHIFT_UART1_PIN_SEL), BIT_UART1_PIN_SEL(num))
|
||||
#define UART2_PIN_CTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_UART_MUX_CTRL, BIT_UART2_PIN_EN, ctrl)
|
||||
#define UART2_PIN_SEL(num) HAL_PERL_ON_PIN_SEL(REG_UART_MUX_CTRL, (BIT_MASK_UART2_PIN_SEL << BIT_SHIFT_UART2_PIN_SEL), BIT_UART2_PIN_SEL(num))
|
||||
|
||||
//284 REG_SPI_MUX_CTRL
|
||||
#define SPI0_PIN_CTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_SPI_MUX_CTRL, BIT_SPI0_PIN_EN, ctrl)
|
||||
#define SPI0_PIN_SEL(num) HAL_PERL_ON_PIN_SEL(REG_SPI_MUX_CTRL, (BIT_MASK_SPI0_PIN_SEL << BIT_SHIFT_SPI0_PIN_SEL), BIT_SPI0_PIN_SEL(num))
|
||||
#define SPI1_PIN_CTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_SPI_MUX_CTRL, BIT_SPI1_PIN_EN, ctrl)
|
||||
#define SPI1_PIN_SEL(num) HAL_PERL_ON_PIN_SEL(REG_SPI_MUX_CTRL, (BIT_MASK_SPI1_PIN_SEL << BIT_SHIFT_SPI1_PIN_SEL), BIT_SPI1_PIN_SEL(num))
|
||||
#define SPI2_PIN_CTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_SPI_MUX_CTRL, BIT_SPI2_PIN_EN, ctrl)
|
||||
#define SPI2_PIN_SEL(num) HAL_PERL_ON_PIN_SEL(REG_SPI_MUX_CTRL, (BIT_MASK_SPI2_PIN_SEL << BIT_SHIFT_SPI2_PIN_SEL), BIT_SPI2_PIN_SEL(num))
|
||||
#define SPI0_MULTI_CS_CTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_SPI_MUX_CTRL, BIT_SPI0_MULTI_CS_EN, ctrl)
|
||||
|
||||
//288 REG_I2C_MUX_CTRL
|
||||
#define I2C0_PIN_CTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_I2C_MUX_CTRL, BIT_I2C0_PIN_EN, ctrl)
|
||||
#define I2C0_PIN_SEL(num) HAL_PERL_ON_PIN_SEL(REG_I2C_MUX_CTRL, (BIT_MASK_I2C0_PIN_SEL << BIT_SHIFT_I2C0_PIN_SEL), BIT_I2C0_PIN_SEL(num))
|
||||
#define I2C1_PIN_CTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_I2C_MUX_CTRL, BIT_I2C1_PIN_EN, ctrl)
|
||||
#define I2C1_PIN_SEL(num) HAL_PERL_ON_PIN_SEL(REG_I2C_MUX_CTRL, (BIT_MASK_I2C1_PIN_SEL << BIT_SHIFT_I2C1_PIN_SEL), BIT_I2C1_PIN_SEL(num))
|
||||
#define I2C2_PIN_CTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_I2C_MUX_CTRL, BIT_I2C2_PIN_EN, ctrl)
|
||||
#define I2C2_PIN_SEL(num) HAL_PERL_ON_PIN_SEL(REG_I2C_MUX_CTRL, (BIT_MASK_I2C2_PIN_SEL << BIT_SHIFT_I2C2_PIN_SEL), BIT_I2C2_PIN_SEL(num))
|
||||
#define I2C3_PIN_CTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_I2C_MUX_CTRL, BIT_I2C3_PIN_EN, ctrl)
|
||||
#define I2C3_PIN_SEL(num) HAL_PERL_ON_PIN_SEL(REG_I2C_MUX_CTRL, (BIT_MASK_I2C3_PIN_SEL << BIT_SHIFT_I2C3_PIN_SEL), BIT_I2C3_PIN_SEL(num))
|
||||
|
||||
//28C REG_I2S_MUX_CTRL
|
||||
#define I2S0_PIN_CTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_I2S_MUX_CTRL, BIT_I2S0_PIN_EN, ctrl)
|
||||
#define I2S0_MCK_CTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_I2S_MUX_CTRL, BIT_I2S0_MCK_EN, ctrl)
|
||||
#define I2S0_PIN_SEL(num) HAL_PERL_ON_PIN_SEL(REG_I2S_MUX_CTRL, (BIT_MASK_I2S0_PIN_SEL << BIT_SHIFT_I2S0_PIN_SEL), BIT_I2S0_PIN_SEL(num))
|
||||
#define I2S1_PIN_CTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_I2S_MUX_CTRL, BIT_I2S1_PIN_EN, ctrl)
|
||||
#define I2S1_MCK_CTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_I2S_MUX_CTRL, BIT_I2S1_MCK_EN, ctrl)
|
||||
#define I2S1_PIN_SEL(num) HAL_PERL_ON_PIN_SEL(REG_I2S_MUX_CTRL, (BIT_MASK_I2S1_PIN_SEL << BIT_SHIFT_I2S1_PIN_SEL), BIT_I2S1_PIN_SEL(num))
|
||||
#define PCM0_PIN_CTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_I2S_MUX_CTRL, BIT_PCM0_PIN_EN, ctrl)
|
||||
#define PCM0_PIN_SEL(num) HAL_PERL_ON_PIN_SEL(REG_I2S_MUX_CTRL, (BIT_MASK_PCM0_PIN_SEL << BIT_SHIFT_PCM0_PIN_SEL), BIT_PCM0_PIN_SEL(num))
|
||||
#define PCM1_PIN_CTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_I2S_MUX_CTRL, BIT_PCM1_PIN_EN, ctrl)
|
||||
#define PCM1_PIN_SEL(num) HAL_PERL_ON_PIN_SEL(REG_I2S_MUX_CTRL, (BIT_MASK_PCM1_PIN_SEL << BIT_SHIFT_PCM1_PIN_SEL), BIT_PCM1_PIN_SEL(num))
|
||||
|
||||
//2A0 HCI_PINMUX_CTRL
|
||||
#define SDIOD_PIN_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_HCI_PINMUX_CTRL, BIT_HCI_SDIOD_PIN_EN, ctrl)
|
||||
#define SDIOH_PIN_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_HCI_PINMUX_CTRL, BIT_HCI_SDIOH_PIN_EN, ctrl)
|
||||
#define MII_PIN_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_HCI_PINMUX_CTRL, BIT_HCI_MII_PIN_EN, ctrl)
|
||||
|
||||
//2A4 WL_PINMUX_CTRL
|
||||
#define LED_PIN_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_WL_PINMUX_CTRL, BIT_WL_LED_PIN_EN, ctrl)
|
||||
#define LED_PIN_SEL(num) HAL_PERL_ON_PIN_SEL(REG_WL_PINMUX_CTRL, (BIT_MASK_WL_LED_PIN_SEL << BIT_SHIFT_WL_LED_PIN_SEL), BIT_WL_LED_PIN_SEL(num))
|
||||
#define ANT0_PIN_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_WL_PINMUX_CTRL, BIT_WL_ANT0_PIN_EN, ctrl)
|
||||
#define ANT1_PIN_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_WL_PINMUX_CTRL, BIT_WL_ANT1_PIN_EN, ctrl)
|
||||
#define BTCOEX_PIN_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_WL_PINMUX_CTRL, BIT_WL_BTCOEX_PIN_EN, ctrl)
|
||||
#define BTCMD_PIN_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_WL_PINMUX_CTRL, BIT_WL_BTCMD_PIN_EN, ctrl)
|
||||
#define NFC_PIN_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_WL_PINMUX_CTRL, BIT_NFC_PIN_EN, ctrl)
|
||||
|
||||
//2AC PWM_PINMUX_CTRL
|
||||
#define PWM0_PIN_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PWM_PINMUX_CTRL, BIT_PWM0_PIN_EN, ctrl)
|
||||
#define PWM0_PIN_SEL(num) HAL_PERL_ON_PIN_SEL(REG_PWM_PINMUX_CTRL, (BIT_MASK_PWM0_PIN_SEL << BIT_SHIFT_PWM0_PIN_SEL), BIT_PWM0_PIN_SEL(num))
|
||||
#define PWM1_PIN_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PWM_PINMUX_CTRL, BIT_PWM1_PIN_EN, ctrl)
|
||||
#define PWM1_PIN_SEL(num) HAL_PERL_ON_PIN_SEL(REG_PWM_PINMUX_CTRL, (BIT_MASK_PWM1_PIN_SEL << BIT_SHIFT_PWM1_PIN_SEL), BIT_PWM1_PIN_SEL(num))
|
||||
#define PWM2_PIN_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PWM_PINMUX_CTRL, BIT_PWM2_PIN_EN, ctrl)
|
||||
#define PWM2_PIN_SEL(num) HAL_PERL_ON_PIN_SEL(REG_PWM_PINMUX_CTRL, (BIT_MASK_PWM2_PIN_SEL << BIT_SHIFT_PWM2_PIN_SEL), BIT_PWM2_PIN_SEL(num))
|
||||
#define PWM3_PIN_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PWM_PINMUX_CTRL, BIT_PWM3_PIN_EN, ctrl)
|
||||
#define PWM3_PIN_SEL(num) HAL_PERL_ON_PIN_SEL(REG_PWM_PINMUX_CTRL, (BIT_MASK_PWM3_PIN_SEL << BIT_SHIFT_PWM3_PIN_SEL), BIT_PWM3_PIN_SEL(num))
|
||||
#define ETE0_PIN_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PWM_PINMUX_CTRL, BIT_ETE0_PIN_EN, ctrl)
|
||||
#define ETE0_PIN_SEL(num) HAL_PERL_ON_PIN_SEL(REG_PWM_PINMUX_CTRL, (BIT_MASK_ETE0_PIN_SEL << BIT_SHIFT_ETE0_PIN_SEL), BIT_ETE0_PIN_SEL(num))
|
||||
#define ETE1_PIN_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PWM_PINMUX_CTRL, BIT_ETE1_PIN_EN, ctrl)
|
||||
#define ETE1_PIN_SEL(num) HAL_PERL_ON_PIN_SEL(REG_PWM_PINMUX_CTRL, (BIT_MASK_ETE1_PIN_SEL << BIT_SHIFT_ETE1_PIN_SEL), BIT_ETE1_PIN_SEL(num))
|
||||
#define ETE2_PIN_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PWM_PINMUX_CTRL, BIT_ETE2_PIN_EN, ctrl)
|
||||
#define ETE2_PIN_SEL(num) HAL_PERL_ON_PIN_SEL(REG_PWM_PINMUX_CTRL, (BIT_MASK_ETE2_PIN_SEL << BIT_SHIFT_ETE2_PIN_SEL), BIT_ETE2_PIN_SEL(num))
|
||||
#define ETE3_PIN_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PWM_PINMUX_CTRL, BIT_ETE3_PIN_EN, ctrl)
|
||||
#define ETE3_PIN_SEL(num) HAL_PERL_ON_PIN_SEL(REG_PWM_PINMUX_CTRL, (BIT_MASK_ETE3_PIN_SEL << BIT_SHIFT_ETE3_PIN_SEL), BIT_ETE3_PIN_SEL(num))
|
||||
|
||||
//2C0 CPU_PERIPHERAL_CTRL
|
||||
#define SPI_FLASH_PIN_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_CPU_PERIPHERAL_CTRL, BIT_SPI_FLSH_PIN_EN, ctrl)
|
||||
#define SPI_FLASH_PIN_SEL(num) HAL_PERL_ON_PIN_SEL(REG_CPU_PERIPHERAL_CTRL, (BIT_MASK_SPI_FLSH_PIN_SEL << BIT_SHIFT_SPI_FLSH_PIN_SEL), BIT_SPI_FLSH_PIN_SEL(num))
|
||||
#define SDR_PIN_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_CPU_PERIPHERAL_CTRL, BIT_SDR_PIN_EN, ctrl)
|
||||
#define TRACE_PIN_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_CPU_PERIPHERAL_CTRL, BIT_TRACE_PIN_EN, ctrl)
|
||||
#define LOG_UART_PIN_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_CPU_PERIPHERAL_CTRL, BIT_LOG_UART_PIN_EN, ctrl)
|
||||
#define LOG_UART_IR_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_CPU_PERIPHERAL_CTRL, BIT_LOG_UART_IR_EN, ctrl)
|
||||
|
||||
//300 REG_PESOC_MEM_CTRL
|
||||
#define SDR_DDL_FCTRL(ctrl) HAL_PERL_ON_PIN_SEL(REG_PESOC_MEM_CTRL, (BIT_MASK_PESOC_SDR_DDL_CTRL << BIT_SHIFT_PESOC_SDR_DDL_CTRL), BIT_PESOC_SDR_DDL_CTRL(ctrl))
|
||||
#define FLASH_DDL_FCTRL(ctrl) HAL_PERL_ON_PIN_SEL(REG_PESOC_MEM_CTRL, (BIT_MASK_PESOC_FLASH_DDL_CTRL << BIT_SHIFT_PESOC_FLASH_DDL_CTRL), BIT_PESOC_FLASH_DDL_CTRL(ctrl))
|
||||
|
||||
//304 REG_PESOC_SOC_CTRL
|
||||
#define SRAM_MUX_CFG(num) HAL_PERL_ON_PIN_SEL(REG_PESOC_SOC_CTRL, (BIT_MASK_PESOC_SRAM_MUX_CFG << BIT_SHIFT_PESOC_SRAM_MUX_CFG), BIT_PESOC_SRAM_MUX_CFG(num))
|
||||
#define LX_WL_SWAP_CTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_SOC_CTRL, BIT_PESOC_LX_WL_SWAP_SEL, ctrl)
|
||||
#define LX_MST_SWAP_CTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_SOC_CTRL, BIT_PESOC_LX_MST_SWAP_SEL, ctrl)
|
||||
#define LX_SLV_SWAP_CTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_SOC_CTRL, BIT_PESOC_LX_SLV_SWAP_SEL, ctrl)
|
||||
#define MII_LX_WRAPPER_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_SOC_CTRL, BIT_PESOC_MII_LX_WRAPPER_EN, ctrl)
|
||||
#define MII_LX_MST_SWAP_CTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_SOC_CTRL, BIT_PESOC_MII_LX_MST_SWAP_SEL, ctrl)
|
||||
#define MII_LX_SLV_SWAP_CTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_SOC_CTRL, BIT_PESOC_MII_LX_SLV_SWAP_SEL, ctrl)
|
||||
#define GDMA_CFG(num) HAL_PERL_ON_PIN_SEL(REG_PESOC_SOC_CTRL, (BIT_MASK_PESOC_GDMA_CFG << BIT_SHIFT_PESOC_GDMA_CFG), BIT_PESOC_GDMA_CFG(num))
|
||||
|
||||
//308 PESOC_PERI_CTRL
|
||||
#define SPI_RN_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PESOC_PERI_CTRL, BIT_SOC_FUNC_SPI_RN, ctrl)
|
||||
|
||||
//320 GPIO_SHTDN_CTRL
|
||||
#define GPIO_GPA_SHTDN_N_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_GPIO_SHTDN_CTRL, BIT_GPIO_GPA_SHTDN_N, ctrl)
|
||||
#define GPIO_GPB_SHTDN_N_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_GPIO_SHTDN_CTRL, BIT_GPIO_GPB_SHTDN_N, ctrl)
|
||||
#define GPIO_GPC_SHTDN_N_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_GPIO_SHTDN_CTRL, BIT_GPIO_GPC_SHTDN_N, ctrl)
|
||||
#define GPIO_GPD_SHTDN_N_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_GPIO_SHTDN_CTRL, BIT_GPIO_GPD_SHTDN_N, ctrl)
|
||||
#define GPIO_GPE_SHTDN_N_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_GPIO_SHTDN_CTRL, BIT_GPIO_GPE_SHTDN_N, ctrl)
|
||||
#define GPIO_GPF_SHTDN_N_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_GPIO_SHTDN_CTRL, BIT_GPIO_GPF_SHTDN_N, ctrl)
|
||||
#define GPIO_GPG_SHTDN_N_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_GPIO_SHTDN_CTRL, BIT_GPIO_GPG_SHTDN_N, ctrl)
|
||||
#define GPIO_GPH_SHTDN_N_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_GPIO_SHTDN_CTRL, BIT_GPIO_GPH_SHTDN_N, ctrl)
|
||||
#define GPIO_GPI_SHTDN_N_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_GPIO_SHTDN_CTRL, BIT_GPIO_GPI_SHTDN_N, ctrl)
|
||||
#define GPIO_GPJ_SHTDN_N_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_GPIO_SHTDN_CTRL, BIT_GPIO_GPJ_SHTDN_N, ctrl)
|
||||
#define GPIO_GPK_SHTDN_N_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_GPIO_SHTDN_CTRL, BIT_GPIO_GPK_SHTDN_N, ctrl)
|
||||
|
||||
//374
|
||||
#define EGTIM_FCTRL(ctrl) HAL_PERL_ON_FUNC_CTRL(REG_PERI_EGTIM_CTRL, BIT_PERI_EGTIM_EN, ctrl)
|
||||
#define EGTIM_RSIG_SEL(num) HAL_PERL_ON_PIN_SEL(REG_PERI_EGTIM_CTRL, (BIT_MASK_PERI_EGTIM_REF_SIG_SEL << BIT_SHIFT_PERI_EGTIM_REF_SIG_SEL), BIT_PERI_EGTIM_REF_SIG_SEL(num))
|
||||
#define EGTIME_PIN_G0_OPT_SEL(num) HAL_PERL_ON_PIN_SEL(REG_PERI_EGTIM_CTRL, (BIT_MASK_PERI_EGTIM_PIN_GROUP0_OPT_SEL << BIT_SHIFT_PERI_EGTIM_PIN_GROUP0_OPT_SEL), BIT_PERI_EGTIM_PIN_GROUP0_OPT_SEL(num))
|
||||
#define EGTIME_PIN_G1_OPT_SEL(num) HAL_PERL_ON_PIN_SEL(REG_PERI_EGTIM_CTRL, (BIT_MASK_PERI_EGTIM_PIN_GROUP1_OPT_SEL << BIT_SHIFT_PERI_EGTIM_PIN_GROUP1_OPT_SEL), BIT_PERI_EGTIM_PIN_GROUP1_OPT_SEL(num))
|
||||
#define EGTIME_PIN_G2_OPT_SEL(num) HAL_PERL_ON_PIN_SEL(REG_PERI_EGTIM_CTRL, (BIT_MASK_PERI_EGTIM_PIN_GROUP2_OPT_SEL << BIT_SHIFT_PERI_EGTIM_PIN_GROUP2_OPT_SEL), BIT_PERI_EGTIM_PIN_GROUP2_OPT_SEL(num))
|
||||
|
||||
|
||||
#endif //_HAL_PERI_ON_H_
|
||||
|
||||
|
|
@ -0,0 +1,140 @@
|
|||
/*
|
||||
* hal_pinmux.c
|
||||
*
|
||||
* Created on: 08/10/2016
|
||||
* Author: pvvx
|
||||
*/
|
||||
#include "rtl8195a.h"
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
/*
|
||||
uint8_t GpioFunctionChk(IN uint32_t chip_pin, IN uint8_t Operation);
|
||||
uint32_t GpioIcFunChk(IN uint32_t chip_pin, IN uint8_t Operation);
|
||||
uint8_t FunctionChk(IN uint32_t Function, IN uint32_t PinLocation);
|
||||
uint8_t RTL8710afFunChk(IN uint32_t Function, IN uint32_t PinLocation);
|
||||
void HalJtagPinOff();
|
||||
*/
|
||||
// extern _LONG_CALL_ uint8_t HalPinCtrlRtl8195A(IN uint32_t Function, IN uint32_t PinLocation, IN BOOL Operation);
|
||||
// extern HALEFUSEOneByteReadRAM();
|
||||
//-------------------------------------------------------------------------
|
||||
// Data declarations
|
||||
extern uint16_t GPIOState[];
|
||||
#define REG_EFUSE_0xF8 0xF8 // [0xF8] = 0xFC RTL8710AF
|
||||
|
||||
#define RTL8710_DEF_PIN_ON 0
|
||||
|
||||
//----- HalJtagPinOff
|
||||
void HalJtagPinOff(void)
|
||||
{
|
||||
HalPinCtrlRtl8195A(JTAG, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
#if RTL8710_DEF_PIN_ON
|
||||
|
||||
//----- GpioIcFunChk
|
||||
uint8_t GpioIcFunChk(IN uint32_t chip_pin, IN uint8_t Operation)
|
||||
{
|
||||
uint8_t tst, result;
|
||||
HALEFUSEOneByteReadRAM(HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_EFUSE_CTRL), REG_EFUSE_0xF8, &tst, L25EOUTVOLTAGE);
|
||||
|
||||
tst += 8; // tst = 0xfc+8 = 0x04
|
||||
if ( tst > 7 ) result = 0;
|
||||
else {
|
||||
tst = 1 << tst; // v6 = 0x10
|
||||
if (tst & 0xEF) result = 1;
|
||||
else {
|
||||
result = tst & 0x10;
|
||||
if(result) { // RTL8710AF ?
|
||||
if (chip_pin - 1 <= 2) result = 0; // PA_1, PA_2, PA_3
|
||||
else {
|
||||
result = chip_pin - PC_5; // PC_5
|
||||
if (chip_pin != PC_5)
|
||||
result = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif // RTL8710_DEF_PIN_ON
|
||||
|
||||
//----- GpioFunctionChk
|
||||
uint8_t GpioFunctionChk(IN uint32_t chip_pin, IN uint8_t Operation)
|
||||
{
|
||||
uint8_t result;
|
||||
uint16_t tst;
|
||||
|
||||
#if RTL8710_DEF_PIN_ON
|
||||
result = GpioIcFunChk(chip_pin, Operation);
|
||||
#else
|
||||
result = 1;
|
||||
#endif
|
||||
if(result) {
|
||||
result = 1;
|
||||
tst = 1 << (chip_pin & 0xF);
|
||||
if (!Operation) {
|
||||
tst = GPIOState[chip_pin >> 4] & (~tst);
|
||||
GPIOState[chip_pin >> 4] = tst;
|
||||
return result;
|
||||
}
|
||||
if (!(GPIOState[chip_pin >> 4] & tst)) {
|
||||
tst |= GPIOState[chip_pin >> 4];
|
||||
GPIOState[chip_pin >> 4] = tst;
|
||||
return result;
|
||||
}
|
||||
result = 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#if RTL8710_DEF_PIN_ON
|
||||
//----- RTL8710afFunChk
|
||||
uint8_t RTL8710afFunChk(IN uint32_t Function, IN uint32_t PinLocation)
|
||||
{
|
||||
uint8_t result;
|
||||
if (Function == SPI0_MCS) // SPI0_MCS
|
||||
return PinLocation - 1 + (PinLocation - 1 <= 0) - (PinLocation - 1);
|
||||
if (Function > I2C0) {
|
||||
if (Function == I2S1) goto LABEL_15;
|
||||
if(Function > I2S1) {
|
||||
if(Function == JTAG || Function == LOG_UART) return 1;
|
||||
}
|
||||
else if(Function == I2C3) goto LABEL_15;
|
||||
return 0;
|
||||
}
|
||||
if(Function == UART2) goto LABEL_15;
|
||||
if(Function == SPI0)
|
||||
return PinLocation - 1 + (PinLocation - 1 <= 0) - (PinLocation - 1);
|
||||
if (Function != UART0) return 0;
|
||||
LABEL_15:
|
||||
result = 1 - PinLocation;
|
||||
if (PinLocation > 1) result = 0;
|
||||
return result;
|
||||
}
|
||||
#endif // RTL8710_DEF_PIN_ON
|
||||
|
||||
//----- FunctionChk
|
||||
uint8_t FunctionChk( IN uint32_t Function, IN uint32_t PinLocation)
|
||||
{
|
||||
#if RTL8710_DEF_PIN_ON
|
||||
uint8_t result, tst;
|
||||
HALEFUSEOneByteReadRAM(HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_EFUSE_CTRL), REG_EFUSE_0xF8, &tst, L25EOUTVOLTAGE);
|
||||
tst += 8; // tst = 0xfc+8 = 0x04
|
||||
if ( tst > 7 ) result = 0;
|
||||
else {
|
||||
tst = 1 << tst; // v6 = 0x10
|
||||
if (tst & 0xEF) result = 1;
|
||||
else {
|
||||
result = tst & 0x10;
|
||||
if (tst & 0x10)
|
||||
result = RTL8710afFunChk(Function, PinLocation);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
#else
|
||||
return 1;
|
||||
#endif // RTL8710_DEF_PIN_ON
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
#ifndef _HAL_PINMUX_
|
||||
#define _HAL_PINMUX_
|
||||
|
||||
|
||||
//Function Index
|
||||
#define UART0 0
|
||||
#define UART1 1
|
||||
#define UART2 2
|
||||
#define SPI0 8
|
||||
#define SPI1 9
|
||||
#define SPI2 10
|
||||
#define SPI0_MCS 15
|
||||
#define I2C0 16
|
||||
#define I2C1 17
|
||||
#define I2C2 18
|
||||
#define I2C3 19
|
||||
#define I2S0 24
|
||||
#define I2S1 25
|
||||
#define PCM0 28
|
||||
#define PCM1 29
|
||||
#define ADC0 32
|
||||
#define DAC0 36
|
||||
#define DAC1 37
|
||||
#define SDIOD 64
|
||||
#define SDIOH 65
|
||||
#define USBOTG 66
|
||||
#define MII 88
|
||||
#define WL_LED 96
|
||||
#define WL_ANT0 104
|
||||
#define WL_ANT1 105
|
||||
#define WL_BTCOEX 108
|
||||
#define WL_BTCMD 109
|
||||
#define NFC 112
|
||||
#define PWM0 160
|
||||
#define PWM1 161
|
||||
#define PWM2 162
|
||||
#define PWM3 163
|
||||
#define ETE0 164
|
||||
#define ETE1 165
|
||||
#define ETE2 166
|
||||
#define ETE3 167
|
||||
#define EGTIM 168
|
||||
#define SPI_FLASH 196
|
||||
#define SDR 200
|
||||
#define JTAG 216
|
||||
#define TRACE 217
|
||||
#define LOG_UART 220
|
||||
#define LOG_UART_IR 221
|
||||
#define SIC 224
|
||||
#define EEPROM 225
|
||||
#define DEBUG 226
|
||||
|
||||
//Location Index(Pin Mux Selection)
|
||||
#define S0 0
|
||||
#define S1 1
|
||||
#define S2 2
|
||||
#define S3 3
|
||||
|
||||
_LONG_CALL_ uint8_t
|
||||
HalPinCtrlRtl8195A(
|
||||
IN uint32_t Function,
|
||||
IN uint32_t PinLocation,
|
||||
IN BOOL Operation);
|
||||
|
||||
uint8_t GpioFunctionChk(
|
||||
IN uint32_t chip_pin,
|
||||
IN uint8_t Operation);
|
||||
|
||||
uint8_t
|
||||
FunctionChk(
|
||||
IN uint32_t Function,
|
||||
IN uint32_t PinLocation
|
||||
);
|
||||
|
||||
#endif //_HAL_PINMUX_
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _HAL_PLATFORM_
|
||||
#define _HAL_PLATFORM_
|
||||
|
||||
#define ROMVERSION 0x03
|
||||
#define ROMINFORMATION (ROMVERSION)
|
||||
|
||||
#define SYSTEM_CLK PLATFORM_CLOCK
|
||||
|
||||
#define PERIPHERAL_IRQ_STATUS 0x04
|
||||
#define PERIPHERAL_IRQ_MODE 0x08
|
||||
#define PERIPHERAL_IRQ_EN 0x0C
|
||||
#define LP_PERI_EXT_IRQ_STATUS 0x24
|
||||
#define LP_PERI_EXT_IRQ_MODE 0x28
|
||||
#define LP_PERI_EXT_IRQ_EN 0x2C
|
||||
|
||||
#define PERIPHERAL_IRQ_ALL_LEVEL 0
|
||||
|
||||
#define TIMER_CLK 32*1000
|
||||
|
||||
#define SDR_SDRAM_BASE 0x30000000
|
||||
#define SYSTEM_CTRL_BASE 0x40000000
|
||||
#define PERI_ON_BASE 0x40000000
|
||||
#define SPI_FLASH_BASE 0x98000000
|
||||
|
||||
//3 Peripheral IP Base Address
|
||||
|
||||
#define GPIO_REG_BASE 0x40001000
|
||||
#define TIMER_REG_BASE 0x40002000
|
||||
#define VENDOR_REG_BASE 0x40002800
|
||||
#define NFC_INTERFACE_BASE 0x40002400
|
||||
#define LOG_UART_REG_BASE 0x40003000
|
||||
#define I2C2_REG_BASE 0x40003400
|
||||
#define I2C3_REG_BASE 0x40003800
|
||||
#define SDR_CTRL_BASE 0x40005000
|
||||
#define SPI_FLASH_CTRL_BASE 0x40006000
|
||||
#define ADC_REG_BASE 0x40010000
|
||||
#define DAC_REG_BASE 0x40011000
|
||||
#define UART0_REG_BASE 0x40040000
|
||||
#define UART1_REG_BASE 0x40040400
|
||||
#define UART2_REG_BASE 0x40040800
|
||||
#define SPI0_REG_BASE 0x40042000
|
||||
#define SPI1_REG_BASE 0x40042400
|
||||
#define SPI2_REG_BASE 0x40042800
|
||||
#define I2C0_REG_BASE 0x40044000
|
||||
#define I2C1_REG_BASE 0x40044400
|
||||
#define SDIO_DEVICE_REG_BASE 0x40050000
|
||||
#define MII_REG_BASE 0x40050000
|
||||
#define SDIO_HOST_REG_BASE 0x40058000
|
||||
#define GDMA0_REG_BASE 0x40060000
|
||||
#define GDMA1_REG_BASE 0x40061000
|
||||
#define I2S0_REG_BASE 0x40062000
|
||||
#define I2S1_REG_BASE 0x40063000
|
||||
#define PCM0_REG_BASE 0x40064000
|
||||
#define PCM1_REG_BASE 0x40065000
|
||||
#define CRYPTO_REG_BASE 0x40070000
|
||||
#define WIFI_REG_BASE 0x40080000
|
||||
#define USB_OTG_REG_BASE 0x400C0000
|
||||
|
||||
#define GDMA1_REG_OFF 0x1000
|
||||
#define I2S1_REG_OFF 0x1000
|
||||
#define PCM1_REG_OFF 0x1000
|
||||
#define SSI_REG_OFF 0x400
|
||||
#define RUART_REG_OFF 0x400
|
||||
|
||||
#define CPU_CLK_TYPE_NO 6
|
||||
|
||||
enum _BOOT_TYPE_ {
|
||||
BOOT_FROM_FLASH = 0,
|
||||
BOOT_FROM_SDIO = 1,
|
||||
BOOT_FROM_USB = 2,
|
||||
BOOT_FROM_RSVD = 3,
|
||||
};
|
||||
|
||||
enum _EFUSE_CPU_CLK_ {
|
||||
#if 1
|
||||
CLK_200M = 0,
|
||||
CLK_100M = 1,
|
||||
CLK_50M = 2,
|
||||
CLK_25M = 3,
|
||||
CLK_12_5M = 4,
|
||||
CLK_4M = 5,
|
||||
#else
|
||||
CLK_25M = 0,
|
||||
CLK_200M = 1,
|
||||
CLK_100M = 2,
|
||||
CLK_50M = 3,
|
||||
CLK_12_5M = 4,
|
||||
CLK_4M = 5,
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
#endif //_HAL_PLATFORM_
|
||||
142
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_pwm.c
Normal file
142
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_pwm.c
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* --------------------------
|
||||
* bug fixing: pvvx
|
||||
*/
|
||||
|
||||
|
||||
#include "rtl8195a.h"
|
||||
|
||||
#ifdef CONFIG_PWM_EN
|
||||
#include "hal_pwm.h"
|
||||
#include "hal_timer.h"
|
||||
|
||||
const uint8_t PWMTimerIdx[MAX_PWM_CTRL_PIN]= {3,4,5,2}; // the G-timer ID used for PWM pin 0~3
|
||||
|
||||
/**
|
||||
* @brief Initializes and enable a PWM control pin.
|
||||
*
|
||||
* @param pwm_id: the PWM pin index
|
||||
* @param sel: pin mux selection
|
||||
*
|
||||
* @retval HAL_Status
|
||||
*/
|
||||
HAL_Status
|
||||
HAL_Pwm_Init(
|
||||
HAL_PWM_ADAPTER *pPwmAdapt,
|
||||
uint32_t pwm_id,
|
||||
uint32_t sel
|
||||
)
|
||||
{
|
||||
uint32_t timer_id;
|
||||
|
||||
if (NULL == pPwmAdapt) {
|
||||
DBG_PWM_ERR ("HAL_Pwm_Init: NULL adapter\n");
|
||||
return HAL_ERR_PARA;
|
||||
}
|
||||
|
||||
if ((pwm_id >= MAX_PWM_CTRL_PIN) || (sel > 3)) {
|
||||
DBG_PWM_ERR ("HAL_Pwm_Init: Invalid PWM index(%d), sel(%d)\n", pwm_id, sel);
|
||||
return HAL_ERR_PARA;
|
||||
}
|
||||
|
||||
pPwmAdapt->pwm_id = pwm_id;
|
||||
pPwmAdapt->sel = sel;
|
||||
timer_id = PWMTimerIdx[pwm_id];
|
||||
pPwmAdapt->gtimer_id = timer_id;
|
||||
/*
|
||||
if (_FALSE == FunctionChk((pPwmAdapt->pwm_id + PWM0), pPwmAdapt->sel)) {
|
||||
DBG_PWM_WARN("HAL_Pwm_Init: Warning for RTL8710AF\n");
|
||||
// return HAL_ERR_HW;
|
||||
}
|
||||
*/
|
||||
#ifndef CONFIG_CHIP_E_CUT
|
||||
return HAL_Pwm_Init_8195a(pPwmAdapt);
|
||||
#else
|
||||
return HAL_Pwm_Init_8195a_V04(pPwmAdapt);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Disable a PWM control pin.
|
||||
*
|
||||
* @param pwm_id: the PWM pin index
|
||||
*
|
||||
* @retval None
|
||||
*/
|
||||
void
|
||||
HAL_Pwm_Enable(
|
||||
HAL_PWM_ADAPTER *pPwmAdapt
|
||||
)
|
||||
{
|
||||
if (NULL == pPwmAdapt) {
|
||||
DBG_PWM_ERR ("HAL_Pwm_Enable: NULL adapter\n");
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_CHIP_E_CUT
|
||||
HAL_Pwm_Enable_8195a(pPwmAdapt);
|
||||
#else
|
||||
HAL_Pwm_Enable_8195a_V04(pPwmAdapt);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Disable a PWM control pin.
|
||||
*
|
||||
* @param pwm_id: the PWM pin index
|
||||
*
|
||||
* @retval None
|
||||
*/
|
||||
void
|
||||
HAL_Pwm_Disable(
|
||||
HAL_PWM_ADAPTER *pPwmAdapt
|
||||
)
|
||||
{
|
||||
if (NULL == pPwmAdapt) {
|
||||
DBG_PWM_ERR ("HAL_Pwm_Disable: NULL adapter\n");
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_CHIP_E_CUT
|
||||
HAL_Pwm_Disable_8195a(pPwmAdapt);
|
||||
#else
|
||||
HAL_Pwm_Disable_8195a_V04(pPwmAdapt);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the duty ratio of the PWM pin.
|
||||
*
|
||||
* @param pwm_id: the PWM pin index
|
||||
* @param period: the period time, in micro-second.
|
||||
* @param pulse_width: the pulse width time, in micro-second.
|
||||
*
|
||||
* @retval None
|
||||
*/
|
||||
void
|
||||
HAL_Pwm_SetDuty(
|
||||
HAL_PWM_ADAPTER *pPwmAdapt,
|
||||
uint32_t period,
|
||||
uint32_t pulse_width
|
||||
)
|
||||
{
|
||||
if (NULL == pPwmAdapt) {
|
||||
DBG_PWM_ERR ("HAL_Pwm_SetDuty: NULL adapter\n");
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_CHIP_E_CUT
|
||||
HAL_Pwm_SetDuty_8195a(pPwmAdapt, period, pulse_width);
|
||||
#else
|
||||
HAL_Pwm_SetDuty_8195a_V04(pPwmAdapt, period, pulse_width);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#endif // end of "#ifdef CONFIG_PWM_EN"
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _HAL_PWM_H_
|
||||
#define _HAL_PWM_H_
|
||||
|
||||
#include "basic_types.h"
|
||||
|
||||
#define MAX_PWM_CTRL_PIN 4
|
||||
// the minimum tick time for G-timer is 61 us (clock source = 32768Hz, reload value=1 and reload takes extra 1T)
|
||||
//#define GTIMER_TICK_US 31 // micro-second, 1000000/32768 ~= 30.5
|
||||
#define MIN_GTIMER_TIMEOUT 61 // in micro-sec, use this value to set the g-timer to generate tick for PWM. 61=(1000000/32768)*2
|
||||
#define PWM_GTIMER_TICK_TIME 61 // in micro-sec, use this value to set the g-timer to generate tick for PWM. 61=(1000000/32768)*2
|
||||
|
||||
typedef struct _HAL_PWM_ADAPTER_ {
|
||||
uint8_t pwm_id; // the PWM ID, 0~3
|
||||
uint8_t sel; // PWM Pin selection, 0~3
|
||||
uint8_t gtimer_id; // using G-Timer ID, there are 7 G-timer, but we prefer to use timer 3~6
|
||||
uint8_t enable; // is enabled
|
||||
// uint32_t timer_value; // the G-Timer auto-reload value, source clock is 32768Hz, reload will takes extra 1 tick. To set the time of a tick of PWM
|
||||
uint32_t tick_time; // the tick time for the G-timer
|
||||
uint32_t period; // the period of a PWM control cycle, in PWM tick
|
||||
uint32_t pulsewidth; // the pulse width in a period of a PWM control cycle, in PWM tick. To control the ratio
|
||||
// float duty_ratio; // the dyty ratio = pulswidth/period
|
||||
}HAL_PWM_ADAPTER, *PHAL_PWM_ADAPTER;
|
||||
|
||||
|
||||
extern HAL_Status
|
||||
HAL_Pwm_Init(
|
||||
HAL_PWM_ADAPTER *pPwmAdapt,
|
||||
uint32_t pwm_id,
|
||||
uint32_t sel
|
||||
);
|
||||
|
||||
extern void
|
||||
HAL_Pwm_Enable(
|
||||
HAL_PWM_ADAPTER *pPwmAdapt
|
||||
);
|
||||
|
||||
extern void
|
||||
HAL_Pwm_Disable(
|
||||
HAL_PWM_ADAPTER *pPwmAdapt
|
||||
);
|
||||
|
||||
extern void
|
||||
HAL_Pwm_SetDuty(
|
||||
HAL_PWM_ADAPTER *pPwmAdapt,
|
||||
uint32_t period,
|
||||
uint32_t pulse_width
|
||||
);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,273 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _HAL_SDIO_H_
|
||||
#define _HAL_SDIO_H_
|
||||
|
||||
#include "rtl8195a_sdio.h"
|
||||
|
||||
#if SDIO_API_DEFINED
|
||||
#include "spdio_api.h"
|
||||
#endif
|
||||
|
||||
#if !SDIO_BOOT_DRIVER
|
||||
#include "mailbox.h"
|
||||
#endif
|
||||
#define PURE_SDIO_INIC 0 // is a pure SDIO iNIC device or a SDIO iNIC + peripheral device
|
||||
|
||||
#if SDIO_BOOT_DRIVER
|
||||
typedef struct _HAL_SDIO_ADAPTER_ {
|
||||
uint8_t *pTXBDAddr; /* The TX_BD start address */
|
||||
PSDIO_TX_BD pTXBDAddrAligned; /* The TX_BD start address, it must be 4-bytes aligned */
|
||||
PSDIO_TX_BD_HANDLE pTXBDHdl; /* point to the allocated memory for TX_BD Handle array */
|
||||
uint16_t TXBDWPtr; /* The SDIO TX(Host->Device) BD local write index, different with HW maintained write Index. */
|
||||
uint16_t TXBDRPtr; /* The SDIO TX(Host->Device) BD read index */
|
||||
uint16_t TXBDRPtrReg; /* The SDIO TX(Host->Device) BD read index has been write to HW register */
|
||||
uint16_t reserve1;
|
||||
|
||||
uint8_t *pRXBDAddr; /* The RX_BD start address */
|
||||
PSDIO_RX_BD pRXBDAddrAligned; /* The RX_BD start address, it must be 8-bytes aligned */
|
||||
PSDIO_RX_BD_HANDLE pRXBDHdl; /* point to the allocated memory for RX_BD Handle array */
|
||||
uint16_t RXBDWPtr; /* The SDIO RX(Device->Host) BD write index */
|
||||
uint16_t RXBDRPtr; /* The SDIO RX(Device->Host) BD local read index, different with HW maintained Read Index. */
|
||||
uint16_t IntMask; /* The Interrupt Mask */
|
||||
uint16_t IntStatus; /* The Interrupt Status */
|
||||
uint32_t Events; /* The Event to the SDIO Task */
|
||||
|
||||
uint32_t EventSema; /* Semaphore for SDIO events, use to wakeup the SDIO task */
|
||||
uint8_t CCPWM; /* the value write to register CCPWM, which will sync to Host HCPWM */
|
||||
uint8_t reserve2;
|
||||
uint16_t CCPWM2; /* the value write to register CCPWM2, which will sync to Host HCPWM2 */
|
||||
|
||||
int8_t (*Tx_Callback)(void *pAdapter, uint8_t *pPkt, uint16_t Offset, uint16_t PktSize); /* to hook the WLan driver TX callback function to handle a Packet TX */
|
||||
void *pTxCb_Adapter; /* a pointer will be used to call the TX Callback function,
|
||||
which is from the TX CallBack function register */
|
||||
int8_t (*pTxCallback_Backup)(void *pAdapter, uint8_t *pPkt, uint16_t Offset, uint16_t PktSize); // Use to back up the registered TX Callback function, for MP/Normal mode switch
|
||||
void *pTxCb_Adapter_Backup; // Backup the pTxCb_Adapter, for MP/Normal mode switch
|
||||
_LIST FreeTxPktList; /* The list to queue free Tx packets handler */
|
||||
_LIST RxPktList; /* The list to queue RX packets */
|
||||
_LIST FreeRxPktList; /* The list to queue free Rx packets handler */
|
||||
SDIO_TX_PACKET *pTxPktHandler; /* to store allocated TX Packet handler memory address */
|
||||
SDIO_RX_PACKET *pRxPktHandler; /* to store allocated RX Packet handler memory address */
|
||||
uint32_t RxInQCnt; /* The packet count for Rx In Queue */
|
||||
uint32_t MemAllocCnt; // Memory allocated count, for debug only
|
||||
uint32_t MAllocFailedCnt; // MemAlloc Failed count, for debugging
|
||||
|
||||
// void *pHalOp; /* point to HAL operation function table */
|
||||
} HAL_SDIO_ADAPTER, *PHAL_SDIO_ADAPTER;
|
||||
|
||||
extern BOOL SDIO_Device_Init_Rom(
|
||||
IN PHAL_SDIO_ADAPTER pSDIODev
|
||||
);
|
||||
extern void SDIO_Device_DeInit_Rom(
|
||||
IN PHAL_SDIO_ADAPTER pSDIODev
|
||||
);
|
||||
extern void SDIO_Send_C2H_IOMsg_Rom(
|
||||
IN PHAL_SDIO_ADAPTER pSDIODev,
|
||||
IN uint32_t *C2HMsg
|
||||
);
|
||||
extern uint8_t SDIO_Send_C2H_PktMsg_Rom(
|
||||
IN PHAL_SDIO_ADAPTER pSDIODev,
|
||||
IN uint8_t *C2HMsg,
|
||||
IN uint16_t MsgLen
|
||||
);
|
||||
extern void SDIO_Register_Tx_Callback_Rom(
|
||||
IN PHAL_SDIO_ADAPTER pSDIODev,
|
||||
IN int8_t (*Tx_Callback)(void *pAdapter, uint8_t *pPkt, uint16_t Offset, uint16_t PktSize),
|
||||
IN void *pAdapter
|
||||
);
|
||||
extern int8_t SDIO_Rx_Callback_Rom(
|
||||
IN PHAL_SDIO_ADAPTER pSDIODev,
|
||||
IN void *pData,
|
||||
IN uint16_t Offset,
|
||||
IN uint16_t Length,
|
||||
IN uint8_t CmdType
|
||||
);
|
||||
|
||||
#else // else of "#if SDIO_BOOT_DRIVER"
|
||||
typedef struct _HAL_SDIO_ADAPTER_ {
|
||||
// uint8_t *pTxBuff; /* point to the SDIO TX Buffer */
|
||||
// uint8_t *pTxBuffAligned; /* point to the SDIO TX Buffer with 4-bytes aligned */
|
||||
// uint32_t TXFifoRPtr; /* The SDIO TX(Host->Device) FIFO buffer read pointer */
|
||||
#if SDIO_API_DEFINED
|
||||
void *spdio_priv; /*Data from User*/
|
||||
#endif
|
||||
uint8_t *pTXBDAddr; /* The TX_BD start address */
|
||||
PSDIO_TX_BD pTXBDAddrAligned; /* The TX_BD start address, it must be 4-bytes aligned */
|
||||
PSDIO_TX_BD_HANDLE pTXBDHdl; /* point to the allocated memory for TX_BD Handle array */
|
||||
uint16_t TXBDWPtr; /* The SDIO TX(Host->Device) BD local write index, different with HW maintained write Index. */
|
||||
uint16_t TXBDRPtr; /* The SDIO TX(Host->Device) BD read index */
|
||||
uint16_t TXBDRPtrReg; /* The SDIO TX(Host->Device) BD read index has been write to HW register */
|
||||
|
||||
uint8_t *pRXBDAddr; /* The RX_BD start address */
|
||||
PSDIO_RX_BD pRXBDAddrAligned; /* The RX_BD start address, it must be 8-bytes aligned */
|
||||
PSDIO_RX_BD_HANDLE pRXBDHdl; /* point to the allocated memory for RX_BD Handle array */
|
||||
uint16_t RXBDWPtr; /* The SDIO RX(Device->Host) BD write index */
|
||||
uint16_t RXBDRPtr; /* The SDIO RX(Device->Host) BD local read index, different with HW maintained Read Index. */
|
||||
uint16_t IntMask; /* The Interrupt Mask */
|
||||
uint16_t IntStatus; /* The Interrupt Status */
|
||||
uint32_t Events; /* The Event to the SDIO Task */
|
||||
|
||||
uint8_t CCPWM; /* the value write to register CCPWM, which will sync to Host HCPWM */
|
||||
uint8_t reserve1;
|
||||
uint16_t CCPWM2; /* the value write to register CCPWM2, which will sync to Host HCPWM2 */
|
||||
uint8_t CRPWM; /* sync from Host HRPWM */
|
||||
uint8_t reserve2;
|
||||
uint16_t CRPWM2; /* sync from Host HRPWM2 */
|
||||
|
||||
#if !TASK_SCHEDULER_DISABLED
|
||||
_Sema TxSema; /* Semaphore for SDIO TX, use to wakeup the SDIO TX task */
|
||||
_Sema RxSema; /* Semaphore for SDIO RX, use to wakeup the SDIO RX task */
|
||||
#else
|
||||
uint32_t EventSema; /* Semaphore for SDIO events, use to wakeup the SDIO task */
|
||||
#endif
|
||||
int8_t (*Tx_Callback)(void *pAdapter, uint8_t *pPkt, uint16_t Offset, uint16_t PktSize, uint8_t type); /* to hook the WLan driver TX callback function to handle a Packet TX */
|
||||
void *pTxCb_Adapter; /* a pointer will be used to call the TX Callback function,
|
||||
which is from the TX CallBack function register */
|
||||
#if SDIO_API_DEFINED
|
||||
int8_t (*Rx_Done_Callback)(void *pAdapter, uint8_t *pPkt, uint16_t Offset, uint16_t PktSize, uint8_t type); /* to hook RX done callback function to release packet */
|
||||
void *pRxDoneCb_Adapter; /* a pointer will be used to call the RX Done Callback function,
|
||||
which is from the TX CallBack function register */
|
||||
#endif
|
||||
int8_t (*pTxCallback_Backup)(void *pAdapter, uint8_t *pPkt, uint16_t Offset, uint16_t PktSize, uint8_t type); // Use to back up the registered TX Callback function, for MP/Normal mode switch
|
||||
void *pTxCb_Adapter_Backup; // Backup the pTxCb_Adapter, for MP/Normal mode switch
|
||||
#if SDIO_DEBUG
|
||||
_LIST FreeTxPktList; /* The list to queue free Tx packets handler */
|
||||
SDIO_TX_PACKET *pTxPktHandler; /* to store allocated TX Packet handler memory address */
|
||||
#endif
|
||||
_LIST RxPktList; /* The list to queue RX packets */
|
||||
_LIST FreeRxPktList; /* The list to queue free Rx packets handler */
|
||||
// _LIST RecyclePktList; /* The list to queue packets handler to be recycled */
|
||||
SDIO_RX_PACKET *pRxPktHandler; /* to store allocated RX Packet handler memory address */
|
||||
_Mutex RxMutex; /* The Mutex to protect RxPktList */
|
||||
uint32_t RxInQCnt; /* The packet count for Rx In Queue */
|
||||
#if SDIO_DEBUG
|
||||
_Mutex StatisticMutex; /* The Mutex to protect Statistic data */
|
||||
uint32_t MemAllocCnt; // Memory allocated count, for debug only
|
||||
uint32_t MAllocFailedCnt; // MemAlloc Failed count, for debugging
|
||||
#endif
|
||||
void *pHalOp; /* point to HAL operation function table */
|
||||
RTL_MAILBOX *pMBox; /* the Mail box for other driver module can send message to SDIO driver */
|
||||
|
||||
#ifdef PLATFORM_FREERTOS
|
||||
xTaskHandle xSDIOTxTaskHandle; /* The handle of the SDIO Task for TX, can be used to delte the task */
|
||||
xTaskHandle xSDIORxTaskHandle; /* The handle of the SDIO Task speical for RX, can be used to delte the task */
|
||||
#endif
|
||||
uint8_t RxFifoBusy; /* is the RX BD fetch hardware busy */
|
||||
|
||||
#if SDIO_MP_MODE
|
||||
#if !TASK_SCHEDULER_DISABLED
|
||||
uint32_t MP_Events; /* The Event to the SDIO Task */
|
||||
_Sema MP_EventSema; /* Semaphore for SDIO events, use to wakeup the SDIO task */
|
||||
RTL_MAILBOX *pMP_MBox; /* the Mail box for communication with other driver module */
|
||||
#ifdef PLATFORM_FREERTOS
|
||||
xTaskHandle MP_TaskHandle; /* The handle of the MP loopback Task, can be used to delte the task */
|
||||
#endif // end of "#ifdef PLATFORM_FREERTOS"
|
||||
#endif // end of "#if !TASK_SCHEDULER_DISABLED"
|
||||
// for MP mode
|
||||
RTL_TIMER *pPeriodTimer; /* a timer to calculate throughput periodically */
|
||||
uint8_t MP_ModeEn; /* is in MP mode */
|
||||
uint8_t MP_LoopBackEn; /* is loop-back enabled */
|
||||
uint8_t MP_ContinueTx; /* is continue TX test enabled */
|
||||
uint8_t MP_ContinueRx; /* is continue RX test enabled */
|
||||
uint8_t MP_ContinueRxMode; /* continue RX test mode: static RX Buf, Dyna-Allocate RX Buf, Pre-Allocate RX Buf */
|
||||
uint8_t MP_CRxInfinite; /* is non-stop SDIO RX, no packet count limit */
|
||||
uint16_t MP_CRxSize; /* SDIO RX test packet size */
|
||||
uint8_t *pMP_CRxBuf; // the buffer for continye RX test
|
||||
uint32_t MP_CRxPktCnt; /* SDIO RX test packet count */
|
||||
uint32_t MP_CRxPktPendingCnt; /* SDIO RX test packet pening count */
|
||||
uint32_t MP_TxPktCnt; /* SDIO TX packet count */
|
||||
uint32_t MP_RxPktCnt; /* SDIO RX packet count */
|
||||
uint32_t MP_TxByteCnt; /* SDIO TX Byte count */
|
||||
uint32_t MP_RxByteCnt; /* SDIO RX Byte count */
|
||||
uint32_t MP_TxDropCnt; /* SDIO TX Drop packet count */
|
||||
uint32_t MP_RxDropCnt; /* SDIO RX Drop packet count */
|
||||
|
||||
uint32_t MP_TxPktCntInPeriod; /* SDIO TX packet count in a period */
|
||||
uint32_t MP_RxPktCntInPeriod; /* SDIO RX packet count in a period */
|
||||
uint32_t MP_TxByteCntInPeriod; /* SDIO TX Byte count in a period */
|
||||
uint32_t MP_RxByteCntInPeriod; /* SDIO RX Byte count in a period */
|
||||
|
||||
uint32_t MP_TxAvgTPWin[SDIO_AVG_TP_WIN_SIZE]; /* a window of SDIO TX byte count history, for average throughput calculation */
|
||||
uint32_t MP_RxAvgTPWin[SDIO_AVG_TP_WIN_SIZE]; /* a window of SDIO RX byte count history, for average throughput calculation */
|
||||
uint32_t MP_TxAvgTPWinSum; /* The sum of all byte-count in the window */
|
||||
uint32_t MP_RxAvgTPWinSum; /* The sum of all byte-count in the window */
|
||||
uint8_t OldestTxAvgWinIdx; /* the index of the oldest TX byte count log */
|
||||
uint8_t TxAvgWinCnt; /* the number of log in the Window */
|
||||
uint8_t OldestRxAvgWinIdx; /* the index of the oldest RX byte count log */
|
||||
uint8_t RxAvgWinCnt; /* the number of log in the Window */
|
||||
|
||||
_LIST MP_RxPktList; /* The list to queue RX packets, for MP loopback test */
|
||||
#endif // end of '#if SDIO_MP_MODE'
|
||||
} HAL_SDIO_ADAPTER, *PHAL_SDIO_ADAPTER;
|
||||
#endif // end of "#else of "#if SDIO_BOOT_DRIVER""
|
||||
|
||||
|
||||
typedef struct _HAL_SDIO_OP_ {
|
||||
BOOL (*HalSdioDevInit)(PHAL_SDIO_ADAPTER pSDIODev);
|
||||
void (*HalSdioDevDeInit)(PHAL_SDIO_ADAPTER pSDIODev);
|
||||
void (*HalSdioSendC2HIOMsg)(PHAL_SDIO_ADAPTER pSDIODev, uint32_t *C2HMsg);
|
||||
uint8_t (*HalSdioSendC2HPktMsg)(PHAL_SDIO_ADAPTER pSDIODev, uint8_t *C2HMsg, uint16_t MsgLen);
|
||||
void (*HalSdioRegTxCallback)(PHAL_SDIO_ADAPTER pSDIODev,int8_t (*CallbackFun)(void *pAdapter, uint8_t *pPkt, uint16_t Offset, uint16_t PktSize, uint8_t Type), void *pAdapter);
|
||||
int8_t (*HalSdioRxCallback)(PHAL_SDIO_ADAPTER pSDIODev, void *pData, uint16_t Offset, uint16_t PktSize, uint8_t CmdType);
|
||||
#if SDIO_API_DEFINED
|
||||
void (*HalSdioRegRxDoneCallback)(PHAL_SDIO_ADAPTER pSDIODev,int8_t (*CallbackFun)(void *pAdapter, uint8_t *pPkt, uint16_t Offset, uint16_t PktSize, uint8_t Type), void *pAdapter);
|
||||
#endif
|
||||
#if SDIO_MP_MODE
|
||||
void (*HalSdioDevMPApp)(PHAL_SDIO_ADAPTER pSDIODev, uint16_t argc, uint8_t *argv[]);
|
||||
#endif
|
||||
}HAL_SDIO_OP, *PHAL_SDIO_OP;
|
||||
|
||||
|
||||
extern BOOL SDIO_Device_Init(
|
||||
IN PHAL_SDIO_ADAPTER pSDIODev
|
||||
);
|
||||
extern void SDIO_Device_DeInit(
|
||||
IN PHAL_SDIO_ADAPTER pSDIODev
|
||||
);
|
||||
extern void SDIO_Send_C2H_IOMsg(
|
||||
IN PHAL_SDIO_ADAPTER pSDIODev,
|
||||
IN uint32_t *C2HMsg
|
||||
);
|
||||
extern uint8_t SDIO_Send_C2H_PktMsg(
|
||||
IN PHAL_SDIO_ADAPTER pSDIODev,
|
||||
IN uint8_t *C2HMsg,
|
||||
IN uint16_t MsgLen
|
||||
);
|
||||
extern void SDIO_Register_Tx_Callback(
|
||||
IN PHAL_SDIO_ADAPTER pSDIODev,
|
||||
IN int8_t (*Tx_Callback)(void *pAdapter, uint8_t *pPkt, uint16_t Offset, uint16_t PktSize, uint8_t Type),
|
||||
IN void *pAdapter
|
||||
);
|
||||
#if SDIO_API_DEFINED
|
||||
extern void SDIO_Register_Rx_Done_Callback(
|
||||
IN PHAL_SDIO_ADAPTER pSDIODev,
|
||||
IN int8_t (*Rx_Done_Callback)(void *pAdapter, uint8_t *pPkt, uint16_t Offset, uint16_t PktSize, uint8_t Type),
|
||||
IN void *pAdapter
|
||||
);
|
||||
#endif
|
||||
extern int8_t SDIO_Rx_Callback(
|
||||
IN PHAL_SDIO_ADAPTER pSDIODev,
|
||||
IN void *pData,
|
||||
IN uint16_t Offset,
|
||||
IN uint16_t Length,
|
||||
IN uint8_t CmdType
|
||||
);
|
||||
#if SDIO_MP_MODE
|
||||
extern void SDIO_DeviceMPApp(
|
||||
IN PHAL_SDIO_ADAPTER pSDIODev,
|
||||
IN uint16_t argc,
|
||||
IN uint8_t *argv[]
|
||||
);
|
||||
#endif
|
||||
|
||||
extern PHAL_SDIO_ADAPTER pgSDIODev;
|
||||
extern void HalSdioInit(void);
|
||||
extern void HalSdioDeInit(void);
|
||||
#endif // #ifndef _HAL_SDIO_H_
|
||||
|
|
@ -0,0 +1,130 @@
|
|||
/*
|
||||
* hal_sdio_host.c (disasm hal_sdio_host.o)
|
||||
*
|
||||
* RTL8710/11 pvvx 12/2016
|
||||
*/
|
||||
#include "rtl8195a.h"
|
||||
#ifdef CONFIG_SDIO_HOST_EN
|
||||
#include "sd.h"
|
||||
#include "sdio_host.h"
|
||||
#include "hal_sdio_host.h"
|
||||
#include "rtl8195a_sdio_host.h"
|
||||
#include "hal_pinmux.h"
|
||||
//#ifdef RTL8710AF
|
||||
#include "hal_gpio.h"
|
||||
#include "PinNames.h"
|
||||
#include "hal_gpio.h"
|
||||
//#endif
|
||||
//-------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Data declarations
|
||||
|
||||
//----- HalSdioHostInit(PHAL_SDIO_HOST_ADAPTER)
|
||||
HAL_Status HalSdioHostInit(IN void *Data) {
|
||||
PHAL_SDIO_HOST_ADAPTER pSdioHostAdapter = (PHAL_SDIO_HOST_ADAPTER) Data;
|
||||
HAL_Status result;
|
||||
if (FunctionChk(SDIOH, 0) != 0) {
|
||||
if (pSdioHostAdapter != NULL) {
|
||||
if (HalSdioHostInitHostRtl8195a(pSdioHostAdapter) != HAL_OK) {
|
||||
result = HAL_ERR_HW;
|
||||
} else {
|
||||
result = HalSdioHostInitCardRtl8195a(pSdioHostAdapter);
|
||||
if (result == HAL_OK) {
|
||||
REG_POWER_STATE RegPwrState;
|
||||
RegPwrState.FuncIdx = SDIOH;
|
||||
RegPwrState.PwrState = ACT;
|
||||
RegPowerState(RegPwrState);
|
||||
}
|
||||
}
|
||||
} else
|
||||
result = HAL_ERR_PARA;
|
||||
} else
|
||||
result = HAL_ERR_UNKNOWN;
|
||||
return result;
|
||||
}
|
||||
|
||||
//----- HalSdioHostEnable(PHAL_SDIO_HOST_ADAPTER)
|
||||
HAL_Status HalSdioHostEnable(void *Data) {
|
||||
// PHAL_SDIO_HOST_ADAPTER pSdioHostAdapter = (PHAL_SDIO_HOST_ADAPTER) Data;
|
||||
HAL_Status result = HalSdioHostEnableRtl8195a(Data);
|
||||
REG_POWER_STATE RegPwrState;
|
||||
RegPwrState.FuncIdx = SDIOH;
|
||||
RegPwrState.PwrState = ACT;
|
||||
if (result == HAL_OK)
|
||||
RegPowerState(RegPwrState);
|
||||
return result;
|
||||
}
|
||||
|
||||
//----- HalSdioHostDeInit(PHAL_SDIO_HOST_ADAPTER)
|
||||
HAL_Status HalSdioHostDeInit(IN void *Data) {
|
||||
PHAL_SDIO_HOST_ADAPTER pSdioHostAdapter = (PHAL_SDIO_HOST_ADAPTER) Data;
|
||||
REG_POWER_STATE SdioHostPwrState;
|
||||
uint8_t HwState;
|
||||
HAL_Status result;
|
||||
SdioHostPwrState.FuncIdx = SDIOH;
|
||||
SdioHostPwrState.PwrState = ACT;
|
||||
|
||||
QueryRegPwrState(SdioHostPwrState.FuncIdx, &SdioHostPwrState.PwrState,
|
||||
&HwState);
|
||||
if (SdioHostPwrState.PwrState & 0xF7) {
|
||||
HalSdioHostEnable(pSdioHostAdapter);
|
||||
QueryRegPwrState(SdioHostPwrState.FuncIdx, &SdioHostPwrState.PwrState,
|
||||
&HwState);
|
||||
}
|
||||
if (SdioHostPwrState.PwrState == ACT) {
|
||||
SdioHostPwrState.PwrState = INACT;
|
||||
RegPowerState(SdioHostPwrState);
|
||||
}
|
||||
if (pSdioHostAdapter != NULL)
|
||||
result = HalSdioHostDeInitRtl8195a(pSdioHostAdapter);
|
||||
else
|
||||
result = HAL_ERR_PARA;
|
||||
return result;
|
||||
}
|
||||
|
||||
//----- HalSdioHostDisable(PHAL_SDIO_HOST_ADAPTER)
|
||||
HAL_Status HalSdioHostDisable(IN void *Data) {
|
||||
HAL_Status result = HalSdioHostDisableRtl8195a(Data);
|
||||
if (result == HAL_OK) {
|
||||
REG_POWER_STATE RegPwrState;
|
||||
RegPwrState.FuncIdx = SDIOH;
|
||||
RegPwrState.PwrState = SLPCG;
|
||||
RegPowerState(RegPwrState); // 0x0441
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//----- HalSdioHostOpInit(PHAL_SDIO_HOST_ADAPTER)
|
||||
void HalSdioHostOpInit(void *Data) {
|
||||
PHAL_SDIO_HOST_OP phsha = (PHAL_SDIO_HOST_OP)Data;
|
||||
phsha->HalSdioHostInitHost = &HalSdioHostInitHostRtl8195a;
|
||||
phsha->HalSdioHostInitCard = &HalSdioHostInitCardRtl8195a;
|
||||
phsha->HalSdioHostDeInit = &HalSdioHostDeInitRtl8195a;
|
||||
phsha->HalSdioHostRegIrq = &HalSdioHostIrqInitRtl8195a;
|
||||
phsha->HalSdioHostReadBlocksDma = &HalSdioHostReadBlocksDmaRtl8195a;
|
||||
phsha->HalSdioHostWriteBlocksDma = &HalSdioHostWriteBlocksDmaRtl8195a;
|
||||
phsha->HalSdioHostStopTransfer = &HalSdioHostStopTransferRtl8195a;
|
||||
phsha->HalSdioHostGetCardStatus = &HalSdioHostGetCardStatusRtl8195a;
|
||||
phsha->HalSdioHostGetSdStatus = &HalSdioHostGetSdStatusRtl8195a;
|
||||
phsha->HalSdioHostChangeSdClock = &HalSdioHostChangeSdClockRtl8195a;
|
||||
phsha->HalSdioHostErase = &HalSdioHostEraseRtl8195a;
|
||||
phsha->HalSdioHostGetWriteProtect = &HalSdioHostGetWriteProtectRtl8195a;
|
||||
phsha->HalSdioHostSetWriteProtect = &HalSdioHostSetWriteProtectRtl8195a;
|
||||
|
||||
#if 0 //#ifdef RTL8710AF
|
||||
if(HalGetChipId() != CHIP_ID_8195AM) {
|
||||
GPIOState[0] &= ~((1 << 8) - 1);
|
||||
{
|
||||
for (int i = 0; i <= 6; i++)
|
||||
HAL_GPIO_PullCtrl(i, PullNone);
|
||||
HAL_GPIO_PullCtrl(PA_6, PullDown);
|
||||
HAL_GPIO_PullCtrl(PA_7, PullDown);
|
||||
}
|
||||
// vTaskDelay(1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // CONFIG_SDIO_HOST_EN
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _HAL_SDIO_HOST_H_
|
||||
#define _HAL_SDIO_HOST_H_
|
||||
|
||||
|
||||
#include "rtl8195a_sdio_host.h"
|
||||
|
||||
|
||||
#define SDIO_HOST_WAIT_FOREVER 0xFFFFFFFF
|
||||
|
||||
|
||||
typedef struct _HAL_SDIO_HOST_OP_ {
|
||||
HAL_Status (*HalSdioHostInitHost) (void *Data);
|
||||
HAL_Status (*HalSdioHostInitCard) (void *Data);
|
||||
HAL_Status (*HalSdioHostDeInit) (void *Data);
|
||||
HAL_Status (*HalSdioHostRegIrq) (void *Data);
|
||||
HAL_Status (*HalSdioHostReadBlocksDma) (void *Data, uint64_t ReadAddr, uint32_t BlockCnt);
|
||||
HAL_Status (*HalSdioHostWriteBlocksDma) (void *Data, uint64_t WriteAddr, uint32_t BlockCnt);
|
||||
HAL_Status (*HalSdioHostStopTransfer) (void *Data);
|
||||
HAL_Status (*HalSdioHostGetCardStatus) (void *Data);
|
||||
HAL_Status (*HalSdioHostGetSdStatus) (void *Data);
|
||||
HAL_Status (*HalSdioHostChangeSdClock) (void *Data, uint8_t Frequency);
|
||||
HAL_Status (*HalSdioHostErase) (void *Data, uint64_t StartAddr, uint64_t EndAddr);
|
||||
HAL_Status (*HalSdioHostGetWriteProtect) (void *Data);
|
||||
HAL_Status (*HalSdioHostSetWriteProtect) (void *Data, uint8_t Setting);
|
||||
}HAL_SDIO_HOST_OP, *PHAL_SDIO_HOST_OP;
|
||||
|
||||
// SDIO error type
|
||||
typedef enum _SDIO_ERR_TYPE_ {
|
||||
SDIO_ERR_DAT_CRC = 0x01,
|
||||
SDIO_ERR_CMD_TIMEOUT = 0x02,
|
||||
}SDIO_ERR_TYPE;
|
||||
|
||||
typedef enum _SDIO_XFER_TYPE_{
|
||||
SDIO_XFER_NOR = 0x00, // normal
|
||||
SDIO_XFER_R = 0x01, // read and write block
|
||||
SDIO_XFER_W = 0x02, // read and write block
|
||||
}SDIO_XFER_TYPE;
|
||||
|
||||
typedef struct _HAL_SDIO_HOST_ADAPTER_{
|
||||
IRQ_HANDLE IrqHandle; //+0..
|
||||
ADMA2_DESC_FMT *AdmaDescTbl; //+16
|
||||
uint32_t Response[4]; //+20,24,28,32
|
||||
uint32_t CardOCR; //+36
|
||||
uint32_t CardStatus; //+40
|
||||
uint32_t IsWriteProtect; //+44
|
||||
uint8_t SdStatus[SD_STATUS_LEN]; //+48..
|
||||
uint8_t Csd[CSD_REG_LEN]; //+112..
|
||||
volatile uint8_t CmdCompleteFlg; //+128
|
||||
volatile uint8_t XferCompleteFlg; //+129
|
||||
volatile uint8_t ErrIntFlg; //+130
|
||||
volatile uint8_t CardCurState; //+131
|
||||
uint8_t IsSdhc; //+132
|
||||
uint8_t CurrSdClk; //+133
|
||||
uint16_t RCA; //+134
|
||||
uint16_t SdSpecVer; //+136
|
||||
SDIO_ERR_TYPE errType; //+140
|
||||
SDIO_XFER_TYPE XferType; //+144
|
||||
void (*XferCompCallback)(void *pAdapter);
|
||||
void *XferCompCbPara;
|
||||
void (*ErrorCallback)(void *pAdapter);
|
||||
void *ErrorCbPara;
|
||||
void (*CardInsertCallBack)(void *pAdapter);
|
||||
void *CardInsertCbPara;
|
||||
void (*CardRemoveCallBack)(void *pAdapter);
|
||||
void *CardRemoveCbPara;
|
||||
}HAL_SDIO_HOST_ADAPTER, *PHAL_SDIO_HOST_ADAPTER;
|
||||
|
||||
extern HAL_SDIO_HOST_ADAPTER SdioHostAdapter;
|
||||
|
||||
extern HAL_Status
|
||||
HalSdioHostInit(
|
||||
IN void *Data
|
||||
);
|
||||
|
||||
extern HAL_Status
|
||||
HalSdioHostDeInit(
|
||||
IN void *Data
|
||||
);
|
||||
|
||||
extern HAL_Status
|
||||
HalSdioHostEnable(
|
||||
IN void *Data
|
||||
);
|
||||
|
||||
extern HAL_Status
|
||||
HalSdioHostDisable(
|
||||
IN void *Data
|
||||
);
|
||||
|
||||
extern void
|
||||
HalSdioHostOpInit(
|
||||
IN void *Data
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,191 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _HAL_SDR_CONTROLLER_H_
|
||||
#define _HAL_SDR_CONTROLLER_H_
|
||||
|
||||
#if 1 //def CONFIG_SDR_EN
|
||||
|
||||
typedef enum _DRAM_TYPE_ {
|
||||
DRAM_DDR_1 = 1,
|
||||
DRAM_DDR_2 = 2,
|
||||
DRAM_DDR_3 = 3,
|
||||
DRAM_DDR_4 = 4,
|
||||
DRAM_SDR = 8
|
||||
}DRAM_TYPE;
|
||||
|
||||
typedef enum _DRAM_COLADDR_WTH_ {
|
||||
DRAM_COLADDR_8B = 0,
|
||||
DRAM_COLADDR_9B = 1,
|
||||
DRAM_COLADDR_10B = 2,
|
||||
DRAM_COLADDR_11B = 3,
|
||||
DRAM_COLADDR_12B = 4,
|
||||
DRAM_COLADDR_13B = 5,
|
||||
DRAM_COLADDR_14B = 6,
|
||||
DRAM_COLADDR_15B = 7,
|
||||
DRAM_COLADDR_16B = 8
|
||||
}DRAM_COLADDR_WTH;
|
||||
|
||||
typedef enum _DRAM_BANK_SIZE_ {
|
||||
DRAM_BANK_2 = 0,
|
||||
DRAM_BANK_4 = 1,
|
||||
DRAM_BANK_8 = 2
|
||||
}DRAM_BANK_SIZE;
|
||||
|
||||
typedef enum _DRAM_DQ_WIDTH_ {
|
||||
DRAM_DQ_16 = 0,
|
||||
DRAM_DQ_32 = 1,
|
||||
DRAM_HALF_DQ32 = 2
|
||||
}DRAM_DQ_WIDTH;
|
||||
|
||||
typedef enum _MODE0_BST_LEN_ {
|
||||
BST_LEN_4 = 0,
|
||||
BST_LEN_FLY = 1,
|
||||
BST_LEN_8 = 2
|
||||
}MODE0_BST_LEN;
|
||||
|
||||
typedef enum _MODE0_BST_TYPE_ {
|
||||
SENQUENTIAL = 0,
|
||||
INTERLEAVE = 1
|
||||
}MODE0_BST_TYPE;
|
||||
|
||||
typedef enum _DFI_RATIO_TYPE_ {
|
||||
DFI_RATIO_1 = 0, // DFI= 1:1, or SDR
|
||||
DFI_RATIO_2 = 1,
|
||||
DFI_RATIO_4 = 2
|
||||
}DFI_RATIO_TYPE;
|
||||
|
||||
typedef struct _DRAM_INFO_ {
|
||||
DRAM_TYPE DeviceType;
|
||||
DRAM_COLADDR_WTH ColAddrWth;
|
||||
DRAM_BANK_SIZE Bank;
|
||||
DRAM_DQ_WIDTH DqWidth;
|
||||
}DRAM_INFO;
|
||||
|
||||
typedef struct _DRAM_MODE_REG_INFO_ {
|
||||
MODE0_BST_LEN BstLen;
|
||||
MODE0_BST_TYPE BstType;
|
||||
//enum mode0_cas rd_cas;
|
||||
uint32_t Mode0Cas;
|
||||
uint32_t Mode0Wr;
|
||||
uint32_t Mode1DllEnN;
|
||||
uint32_t Mode1AllLat;
|
||||
uint32_t Mode2Cwl;
|
||||
}DRAM_MODE_REG_INFO;
|
||||
|
||||
typedef struct _DRAM_TIMING_INFO_ {
|
||||
uint32_t TrfcPs;
|
||||
uint32_t TrefiPs;
|
||||
uint32_t WrMaxTck;
|
||||
uint32_t TrcdPs;
|
||||
uint32_t TrpPs;
|
||||
uint32_t TrasPs;
|
||||
uint32_t TrrdTck;
|
||||
uint32_t TwrPs;
|
||||
uint32_t TwtrTck;
|
||||
//uint32_t TrtpPs;
|
||||
uint32_t TmrdTck;
|
||||
uint32_t TrtpTck;
|
||||
uint32_t TccdTck;
|
||||
uint32_t TrcPs;
|
||||
}DRAM_TIMING_INFO;
|
||||
|
||||
|
||||
typedef struct _DRAM_DEVICE_INFO_ {
|
||||
DRAM_INFO *Dev;
|
||||
DRAM_MODE_REG_INFO *ModeReg;
|
||||
DRAM_TIMING_INFO *Timing;
|
||||
uint32_t DdrPeriodPs;
|
||||
DFI_RATIO_TYPE *DfiRate;
|
||||
} DRAM_DEVICE_INFO, *PDRAM_DEVICE_INFO;
|
||||
|
||||
|
||||
//======================================================
|
||||
//DRAM Info
|
||||
#ifdef CONFIG_FPGA
|
||||
#define DRAM_INFO_TYPE DRAM_SDR
|
||||
#define DRAM_INFO_COL_ADDR_WTH DRAM_COLADDR_9B
|
||||
#define DRAM_INFO_BANK_SZ DRAM_BANK_4
|
||||
#define DRAM_INFO_DQ_WTH DRAM_DQ_16
|
||||
#else
|
||||
#define DRAM_INFO_TYPE DRAM_SDR
|
||||
#define DRAM_INFO_COL_ADDR_WTH DRAM_COLADDR_8B
|
||||
#define DRAM_INFO_BANK_SZ DRAM_BANK_2
|
||||
#define DRAM_INFO_DQ_WTH DRAM_DQ_16
|
||||
#endif
|
||||
|
||||
//======================================================
|
||||
//DRAM Timing
|
||||
#ifdef CONFIG_SDR_100MHZ
|
||||
#define DRAM_TIMING_TCK 10000 //ps
|
||||
#endif
|
||||
#ifdef CONFIG_SDR_50MHZ
|
||||
#define DRAM_TIMING_TCK 20000 //ps
|
||||
#endif
|
||||
#ifdef CONFIG_SDR_25MHZ
|
||||
#define DRAM_TIMING_TCK 40000 //ps
|
||||
#endif
|
||||
#ifdef CONFIG_SDR_12_5MHZ
|
||||
#define DRAM_TIMING_TCK 80000 //ps
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
#define DRAM_TIMING_TREF 64000 //us
|
||||
#define DRAM_ROW_NUM 8192 //depends on row bit number
|
||||
|
||||
#define DRAM_TIMING_TRFC 60000 //ps
|
||||
#define DRAM_TIMING_TREFI ((uint32_t)((DRAM_TIMING_TREF*1000)/DRAM_ROW_NUM)*1000) //ps
|
||||
#define DRAM_TIMING_TWRMAXTCK 2 //tck
|
||||
#define DRAM_TIMING_TRCD 15000 //ps
|
||||
#define DRAM_TIMING_TRP 15000 //ps
|
||||
#define DRAM_TIMING_TRAS 42000 //ps
|
||||
#define DRAM_TIMING_TRRD 2 //tck
|
||||
#define DRAM_TIMING_TWR ((uint32_t)(DRAM_TIMING_TCK*2))
|
||||
#define DRAM_TIMING_TWTR 0 //tck
|
||||
#define DRAM_TIMING_TMRD 2 //tck
|
||||
#define DRAM_TIMING_TRTP 0 //tck
|
||||
#define DRAM_TIMING_TCCD 1 //tck
|
||||
#define DRAM_TIMING_TRC 60000 //ps
|
||||
#else
|
||||
|
||||
#define DRAM_TIMING_TREF 66000 //us
|
||||
#define DRAM_ROW_NUM 8192 //depends on row bit number
|
||||
|
||||
#define DRAM_TIMING_TRFC 66000 //ps
|
||||
#define DRAM_TIMING_TREFI 63999800
|
||||
#define DRAM_TIMING_TWRMAXTCK 2 //tck
|
||||
#define DRAM_TIMING_TRCD 15000 //ps
|
||||
#define DRAM_TIMING_TRP 15000 //ps
|
||||
#define DRAM_TIMING_TRAS 37000 //ps
|
||||
#define DRAM_TIMING_TRRD 2 //tck
|
||||
#define DRAM_TIMING_TWR 7000
|
||||
#define DRAM_TIMING_TWTR 0 //tck
|
||||
#define DRAM_TIMING_TMRD 2 //tck
|
||||
#define DRAM_TIMING_TRTP 0 //tck
|
||||
#define DRAM_TIMING_TCCD 1 //tck
|
||||
#define DRAM_TIMING_TRC 60000 //ps
|
||||
#endif
|
||||
|
||||
#define HAL_SDR_WRITE32(addr, value32) HAL_WRITE32(SDR_CTRL_BASE, addr, value32)
|
||||
#define HAL_SDR_WRITE16(addr, value16) HAL_WRITE16(SDR_CTRL_BASE, addr, value16)
|
||||
#define HAL_SDR_WRITE8(addr, value8) HAL_WRITE8(SDR_CTRL_BASE, addr, value8)
|
||||
#define HAL_SDR_READ32(addr) HAL_READ32(SDR_CTRL_BASE, addr)
|
||||
#define HAL_SDR_READ16(addr) HAL_READ16(SDR_CTRL_BASE, addr)
|
||||
#define HAL_SDR_READ8(addr) HAL_READ8(SDR_CTRL_BASE, addr)
|
||||
|
||||
#define HAL_SDRAM_WRITE32(addr, value32) HAL_WRITE32(SDR_SDRAM_BASE, addr, value32)
|
||||
#define HAL_SDRAM_WRITE16(addr, value16) HAL_WRITE16(SDR_SDRAM_BASE, addr, value16)
|
||||
#define HAL_SDRAM_WRITE8(addr, value8) HAL_WRITE8(SDR_SDRAM_BASE, addr, value8)
|
||||
#define HAL_SDRAM_READ32(addr) HAL_READ32(SDR_SDRAM_BASE, addr)
|
||||
#define HAL_SDRAM_READ16(addr) HAL_READ16(SDR_SDRAM_BASE, addr)
|
||||
#define HAL_SDRAM_READ8(addr) HAL_READ8(SDR_SDRAM_BASE, addr)
|
||||
|
||||
#endif // CONFIG_SDR_EN
|
||||
//extern unsigned int rand_x;
|
||||
#endif // end of "#ifndef _HAL_SDR_CONTROLLER_H_"
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,279 @@
|
|||
#ifndef _HAL_SOCPWR_
|
||||
#define _HAL_SOCPWR_
|
||||
|
||||
|
||||
#define MAX_BACKUP_SIZE 129
|
||||
#define MAXFUNC 10
|
||||
#define FSTREG 0xFF
|
||||
|
||||
#define REG_VDR_ANACK_CAL_CTRL 0xA0
|
||||
|
||||
#define PS_MASK 0xFFFFFFFF
|
||||
|
||||
//pwr state
|
||||
#define HWACT 0
|
||||
#define HWCG 1
|
||||
#define HWINACT 2
|
||||
#define UNDEF 3
|
||||
#define ALLMET 0xff
|
||||
|
||||
//SLP
|
||||
#define SLP_STIMER BIT0
|
||||
#define SLP_GTIMER BIT1
|
||||
#define SLP_GPIO BIT2
|
||||
#define SLP_WL BIT3
|
||||
#define SLP_NFC BIT4
|
||||
#define SLP_SDIO BIT5
|
||||
#define SLP_USB BIT6
|
||||
#define SLP_TIMER33 BIT7
|
||||
|
||||
//DSTBY
|
||||
#define DSTBY_STIMER BIT0
|
||||
#define DSTBY_NFC BIT1
|
||||
#define DSTBY_TIMER33 BIT2
|
||||
#define DSTBY_GPIO BIT3
|
||||
|
||||
//DS wake event
|
||||
#define DS_TIMER33 BIT0
|
||||
#define DS_GPIO BIT1
|
||||
|
||||
enum power_state_idx{
|
||||
ACT = 0,
|
||||
WFE,
|
||||
WFI,
|
||||
SNOOZE,
|
||||
SLPCG,
|
||||
SLPPG,
|
||||
DSTBY,
|
||||
DSLP,
|
||||
INACT,
|
||||
MAXSTATE
|
||||
};
|
||||
|
||||
enum clk_idx{
|
||||
ANACK = 0,
|
||||
A33CK = 1,
|
||||
};
|
||||
|
||||
|
||||
typedef struct _power_state_{
|
||||
uint8_t FuncIdx;
|
||||
uint8_t PowerState;
|
||||
}POWER_STATE, *pPOWER_STATE;
|
||||
|
||||
typedef struct _reg_power_state_{
|
||||
uint8_t FuncIdx;
|
||||
uint8_t PwrState;
|
||||
}REG_POWER_STATE, *pPREG_POWER_STATE;
|
||||
|
||||
#if 0
|
||||
typedef struct _power_state_{
|
||||
uint8_t FuncIdx;
|
||||
uint8_t PowerState;
|
||||
uint32_t ReqDuration;
|
||||
uint32_t RegCount;
|
||||
uint32_t RemainDuration;
|
||||
}POWER_STATE, *pPOWER_STATE;
|
||||
|
||||
typedef struct _reg_power_state_{
|
||||
uint8_t FuncIdx;
|
||||
uint8_t PwrState;
|
||||
uint32_t ReqDuration;
|
||||
//uint8_t StateIdx;
|
||||
}REG_POWER_STATE, *pPREG_POWER_STATE;
|
||||
#endif
|
||||
|
||||
typedef struct _power_mgn_{
|
||||
uint8_t ActFuncCount;
|
||||
POWER_STATE PwrState[MAXFUNC];
|
||||
uint8_t CurrentState;
|
||||
uint8_t SDREn;
|
||||
uint32_t MSPbackup[MAX_BACKUP_SIZE];
|
||||
uint32_t CPURegbackup[25];
|
||||
uint32_t CPUPSP;
|
||||
uint32_t WakeEventFlag;
|
||||
BOOL SleepFlag;
|
||||
//uint32_t CPUReg[13];
|
||||
//uint32_t MSBackUp[128];
|
||||
}Power_Mgn, *pPower_Mgn;
|
||||
|
||||
typedef struct _SYS_ADAPTER_ {
|
||||
uint8_t function;
|
||||
}SYS_ADAPTER, *PSYS_ADAPTER;
|
||||
|
||||
extern Power_Mgn PwrAdapter;
|
||||
|
||||
uint8_t ChangeSoCPwrState(
|
||||
IN uint8_t RequestState,
|
||||
IN uint32_t ReqCount
|
||||
);
|
||||
|
||||
void PrintCPU(void);
|
||||
void WakeFromSLPPG(void);
|
||||
void SOCPSTestApp(void *Data);
|
||||
|
||||
|
||||
__inline static void
|
||||
CPURegBackUp(
|
||||
void
|
||||
)
|
||||
{
|
||||
#if defined (__ICCARM__)
|
||||
// TODO: IAR has different way using assembly
|
||||
#elif defined (__GNUC__)
|
||||
//backup cpu reg
|
||||
#if 0
|
||||
asm volatile
|
||||
(
|
||||
"PUSH {PSR, PC, LR, R12,R3,R2,R1,R0}\n"
|
||||
);
|
||||
#endif
|
||||
#if 0
|
||||
asm volatile
|
||||
(
|
||||
"PUSH {r0,r1,r2,r3,r4}\n"
|
||||
);
|
||||
#endif
|
||||
|
||||
asm volatile
|
||||
(
|
||||
|
||||
"MOV %0, r0\n"
|
||||
:"=r"(PwrAdapter.CPURegbackup[0])
|
||||
::"memory"
|
||||
);
|
||||
|
||||
asm volatile
|
||||
(
|
||||
"MOV %0, r1\n"
|
||||
:"=r"(PwrAdapter.CPURegbackup[1])
|
||||
::"memory"
|
||||
);
|
||||
|
||||
asm volatile
|
||||
(
|
||||
"MOV %0, r2\n"
|
||||
:"=r"(PwrAdapter.CPURegbackup[2])
|
||||
::"memory"
|
||||
);
|
||||
|
||||
asm volatile
|
||||
(
|
||||
"MOV %0, r3\n"
|
||||
:"=r"(PwrAdapter.CPURegbackup[3])
|
||||
::"memory"
|
||||
);
|
||||
|
||||
asm volatile
|
||||
(
|
||||
"MOV %0, r4\n"
|
||||
:"=r"(PwrAdapter.CPURegbackup[4])
|
||||
::"memory"
|
||||
);
|
||||
|
||||
asm volatile
|
||||
(
|
||||
"MOV %0, r5\n"
|
||||
:"=r"(PwrAdapter.CPURegbackup[5])
|
||||
::"memory"
|
||||
);
|
||||
|
||||
asm volatile
|
||||
(
|
||||
"MOV %0, r6\n"
|
||||
:"=r"(PwrAdapter.CPURegbackup[6])
|
||||
::"memory"
|
||||
);
|
||||
|
||||
asm volatile
|
||||
(
|
||||
"MOV %0, r7\n"
|
||||
:"=r"(PwrAdapter.CPURegbackup[7])
|
||||
::"memory"
|
||||
);
|
||||
|
||||
asm volatile
|
||||
(
|
||||
"MOV %0, r8\n"
|
||||
:"=r"(PwrAdapter.CPURegbackup[8])
|
||||
::"memory"
|
||||
);
|
||||
|
||||
asm volatile
|
||||
(
|
||||
"MOV %0, r9\n"
|
||||
:"=r"(PwrAdapter.CPURegbackup[9])
|
||||
::"memory"
|
||||
);
|
||||
|
||||
asm volatile
|
||||
(
|
||||
"MOV %0, r10\n"
|
||||
:"=r"(PwrAdapter.CPURegbackup[10])
|
||||
::"memory"
|
||||
);
|
||||
|
||||
asm volatile
|
||||
(
|
||||
"MOV %0, r11\n"
|
||||
:"=r"(PwrAdapter.CPURegbackup[11])
|
||||
::"memory"
|
||||
);
|
||||
asm volatile
|
||||
(
|
||||
"MOV %0, r12\n"
|
||||
:"=r"(PwrAdapter.CPURegbackup[12])
|
||||
::"memory"
|
||||
);
|
||||
|
||||
asm volatile
|
||||
(
|
||||
"MOV %0, r13\n"
|
||||
:"=r"(PwrAdapter.CPURegbackup[13])
|
||||
::"memory"
|
||||
);
|
||||
asm volatile
|
||||
(
|
||||
//"MOV %0, r14\n"
|
||||
"LDR %0, =SLPPG_WAKEUP_POINT\n"
|
||||
"ADD %0, #1\n"
|
||||
:"=r"(PwrAdapter.CPURegbackup[14])
|
||||
::"memory"
|
||||
);
|
||||
asm volatile
|
||||
(
|
||||
"LDR %0, =SLPPG_WAKEUP_POINT\n"
|
||||
"ADD %0, #1\n"
|
||||
:"=r"(PwrAdapter.CPURegbackup[15])
|
||||
::"memory"
|
||||
);
|
||||
asm volatile
|
||||
(
|
||||
"MRS %0, PSR\n"
|
||||
:"=r"(PwrAdapter.CPURegbackup[16])
|
||||
::"memory"
|
||||
);
|
||||
|
||||
#if 1
|
||||
asm volatile
|
||||
(
|
||||
"mov %0, r13\n"
|
||||
"MOV %1, PC\n"
|
||||
"MRS %2, CONTROL\n"
|
||||
"MRS %3, PSP\n"
|
||||
"MRS %4, MSP\n"
|
||||
:"=r"(PwrAdapter.CPURegbackup[24]),"=r"(PwrAdapter.CPURegbackup[23]),"=r"(PwrAdapter.CPURegbackup[22]),"=r"(PwrAdapter.CPURegbackup[21]),"=r"(PwrAdapter.CPURegbackup[20])
|
||||
::"memory"
|
||||
);
|
||||
#endif
|
||||
#ifdef CONFIG_SOC_PS_VERIFY
|
||||
PrintCPU();
|
||||
#endif //#ifdef CONFIG_SOC_PS_VERIFY
|
||||
#endif //#elif defined (__GNUC__)
|
||||
}
|
||||
|
||||
extern void RegPowerState(REG_POWER_STATE RegPwrState);
|
||||
extern void QueryRegPwrState( IN uint8_t FuncIdx, OUT uint8_t* RegState, OUT uint8_t* HwState);
|
||||
|
||||
|
||||
#endif //_HAL_SOCPWR_
|
||||
|
|
@ -0,0 +1,359 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _HAL_SPIFLASH__
|
||||
#define _HAL_SPIFLASH__
|
||||
//======================================================
|
||||
// Header files
|
||||
|
||||
#define SPIC_CALIBRATION_IN_NVM 1 // if store the SPIC calibration data in the NVM
|
||||
#ifndef CONFIG_IMAGE_SEPARATE // Store SPIC Calibration only for seprated image
|
||||
#undef SPIC_CALIBRATION_IN_NVM
|
||||
#define SPIC_CALIBRATION_IN_NVM 0
|
||||
#endif
|
||||
|
||||
//======================================================
|
||||
// Definition
|
||||
#define HAL_SPI_WRITE32(addr, value32) HAL_WRITE32(SPI_FLASH_CTRL_BASE, addr, value32)
|
||||
#define HAL_SPI_WRITE16(addr, value16) HAL_WRITE16(SPI_FLASH_CTRL_BASE, addr, value16)
|
||||
#define HAL_SPI_WRITE8(addr, value8) HAL_WRITE8(SPI_FLASH_CTRL_BASE, addr, value8)
|
||||
#define HAL_SPI_READ32(addr) HAL_READ32(SPI_FLASH_CTRL_BASE, addr)
|
||||
#define HAL_SPI_READ16(addr) HAL_READ16(SPI_FLASH_CTRL_BASE, addr)
|
||||
#define HAL_SPI_READ8(addr) HAL_READ8(SPI_FLASH_CTRL_BASE, addr)
|
||||
|
||||
typedef struct _SPIC_PARA_MODE_ {
|
||||
uint8_t Valid :1; // valid
|
||||
uint8_t CpuClk :3; // CPU clock
|
||||
uint8_t BitMode :2; // Bit mode
|
||||
uint8_t Reserved :2; // reserved
|
||||
} SPIC_PARA_MODE, *PSPIC_PARA_MODE;
|
||||
|
||||
typedef struct _SPIC_INIT_PARA_ {
|
||||
uint8_t BaudRate;
|
||||
uint8_t RdDummyCyle;
|
||||
uint8_t DelayLine;
|
||||
union {
|
||||
uint8_t Rsvd;
|
||||
uint8_t Valid;
|
||||
SPIC_PARA_MODE Mode;
|
||||
};
|
||||
#if defined(E_CUT_ROM_DOMAIN) || (!defined(CONFIG_RELEASE_BUILD_LIBRARIES))
|
||||
uint8_t id[3];
|
||||
uint8_t flashtype;
|
||||
#endif
|
||||
}SPIC_INIT_PARA, *PSPIC_INIT_PARA;
|
||||
|
||||
|
||||
enum _SPIC_BIT_MODE_ {
|
||||
SpicOneBitMode = 0,
|
||||
SpicDualBitMode = 1,
|
||||
SpicQuadBitMode = 2,
|
||||
SpicMaxMode = 3
|
||||
};
|
||||
|
||||
//======================================================
|
||||
// Flash type used
|
||||
#define FLASH_OTHERS 0
|
||||
#define FLASH_MXIC 1
|
||||
#define FLASH_MXIC_4IO 2
|
||||
#define FLASH_WINBOND 3
|
||||
#define FLASH_MICRON 4
|
||||
#define FLASH_EON 5
|
||||
|
||||
//#define FLASH_MXIC_MX25L4006E 0
|
||||
//#define FLASH_MXIC_MX25L8073E 1
|
||||
//#define FLASH_MICRON_N25Q512A 1
|
||||
// The below parts are based on the flash characteristics
|
||||
//====== Flash Command Definition ======
|
||||
//#if FLASH_MICRON_N25Q512A
|
||||
|
||||
/*Common command*/
|
||||
#define FLASH_CMD_WREN 0x06 //write enable
|
||||
#define FLASH_CMD_WRDI 0x04 //write disable
|
||||
#define FLASH_CMD_WRSR 0x01 //write status register
|
||||
#define FLASH_CMD_RDID 0x9F //read idenfication
|
||||
#define FLASH_CMD_RDSR 0x05 //read status register
|
||||
#define FLASH_CMD_RDSFDP 0x5A //Read SFDP
|
||||
#define FLASH_CMD_READ 0x03 //read data
|
||||
#define FLASH_CMD_FREAD 0x0B //fast read data
|
||||
#define FLASH_CMD_PP 0x02 //Page Program
|
||||
#define FLASH_CMD_DREAD 0x3B //Double Output Mode command 1-1-2
|
||||
#define FLASH_CMD_2READ 0xBB // 2 x I/O read command 1-2-2
|
||||
#define FLASH_CMD_QREAD 0x6B // 1I / 4O read command 1-1-4
|
||||
#define FLASH_CMD_4READ 0xEB // 4 x I/O read command 1-4-4
|
||||
#define FLASH_CMD_DPP 0xA2 // 1-1-2
|
||||
#define FLASH_CMD_2PP 0xD2 // 1-2-2
|
||||
#define FLASH_CMD_QPP 0x32 // 1-1-4
|
||||
#define FLASH_CMD_4PP 0x38 //quad page program 1-4-4
|
||||
#define FLASH_CMD_SE 0x20 //Sector Erase
|
||||
#define FLASH_CMD_BE 0xD8 //Block Erase(or 0x52)
|
||||
#define FLASH_CMD_CE 0xC7 //Chip Erase(or 0xC7)
|
||||
#define FLASH_CMD_DP 0xB9 //Deep Power Down
|
||||
#define FLASH_CMD_RDP 0xAB //Release from Deep Power-Down
|
||||
|
||||
/*Micron Special command*/
|
||||
#define FLASH_CMD_DE 0xC4 // DIE ERASE
|
||||
#define FLASH_CMD_4PP2 0x12 // 4-BYTE PAGE PROGRAM
|
||||
#define FLASH_CMD_RFSR 0x70 // READ FLAG STATUS REGISTER
|
||||
#define FLASH_CMD_CFSR 0x50 // CLEAR FLAG STATUS REGISTER
|
||||
#define FLASH_CMD_RNCR 0xB5 // READ NONVOLATILE CONFIGURATION REGISTER
|
||||
#define FLASH_CMD_WNCR 0xB1 // WRITE NONVOLATILE CONFIGURATION REGISTER
|
||||
#define FLASH_CMD_RVCR 0x85 // READ VOLATILE CONFIGURATION REGISTER
|
||||
#define FLASH_CMD_WVCR 0x81 // WRITE VOLATILE CONFIGURATION REGISTER
|
||||
#define FLASH_CMD_REVCR 0x65 // READ ENHANCED VOLATILE CONFIGURATION REGISTER
|
||||
#define FLASH_CMD_WEVCR 0x61 // WRITE ENHANCED VOLATILE CONFIGURATION REGISTER
|
||||
#define FLASH_CMD_REAR 0xC8 // READ EXTENDED ADDRESS REGISTER
|
||||
#define FLASH_CMD_WEAR 0xC5 // WRITE EXTENDED ADDRESS REGISTER
|
||||
#define FLASH_CMD_ENQUAD 0x35 // ENTER QUAD
|
||||
#define FLASH_CMD_EXQUAD 0xF5 // EXIT QUAD
|
||||
#define FLASH_CMD_ROTPA 0x4B // READ OTP ARRAY
|
||||
#define FLASH_CMD_POTPA 0x42 // PROGRAM OTP ARRAY
|
||||
|
||||
/*MXIC Special command*/
|
||||
#define FLASH_CMD_RDCR 0x15 //read configurate register
|
||||
#define FLASH_CMD_REMS2 0xEF // read ID for 2x I/O mode
|
||||
#define FLASH_CMD_REMS4 0xDF // read ID for 4x I/O mode
|
||||
#define FLASH_CMD_ENSO 0xB1 // enter secured OTP
|
||||
#define FLASH_CMD_EXSO 0xC1 // exit secured OTP
|
||||
#define FLASH_CMD_RDSCUR 0x2B // read security register
|
||||
#define FLASH_CMD_WRSCUR 0x2F // write security register
|
||||
|
||||
/* EON Special command*/
|
||||
#define FLASH_CMD_EOTPM 0x3A // Enter OTP Mode (3Ah)
|
||||
|
||||
//#endif
|
||||
#if 0
|
||||
#if FLASH_MXIC_MX25L4006E
|
||||
#define FLASH_CMD_WREN 0x06 //write enable
|
||||
#define FLASH_CMD_WRDI 0x04 //write disable
|
||||
#define FLASH_CMD_WRSR 0x01 //write status register
|
||||
#define FLASH_CMD_RDID 0x9F //read idenfication
|
||||
#define FLASH_CMD_RDSR 0x05 //read status register
|
||||
#define FLASH_CMD_READ 0x03 //read data
|
||||
#define FLASH_CMD_FREAD 0x0B //fast read data
|
||||
#define FLASH_CMD_RDSFDP 0x5A //Read SFDP
|
||||
#define FLASH_CMD_RES 0xAB //Read Electronic ID
|
||||
#define FLASH_CMD_REMS 0x90 //Read Electronic Manufacturer & Device ID
|
||||
#define FLASH_CMD_DREAD 0x3B //Double Output Mode command
|
||||
#define FLASH_CMD_SE 0x20 //Sector Erase
|
||||
#define FLASH_CMD_BE 0xD8 //Block Erase(or 0x52)
|
||||
#define FLASH_CMD_CE 0x60 //Chip Erase(or 0xC7)
|
||||
#define FLASH_CMD_PP 0x02 //Page Program
|
||||
#define FLASH_CMD_DP 0xB9 //Deep Power Down
|
||||
#define FLASH_CMD_RDP 0xAB //Release from Deep Power-Down
|
||||
#define FLASH_CMD_RDCR 0x15 //read configurate register
|
||||
#define FLASH_CMD_2READ 0xBB // 2 x I/O read command
|
||||
#define FLASH_CMD_4READ 0xEB // 4 x I/O read command
|
||||
#define FLASH_CMD_QREAD 0x6B // 1I / 4O read command
|
||||
#define FLASH_CMD_4PP 0x38 //quad page program
|
||||
#define FLASH_CMD_FF 0xFF //Release Read Enhanced
|
||||
#define FLASH_CMD_REMS2 0xEF // read ID for 2x I/O mode
|
||||
#define FLASH_CMD_REMS4 0xDF // read ID for 4x I/O mode
|
||||
#define FLASH_CMD_ENSO 0xB1 // enter secured OTP
|
||||
#define FLASH_CMD_EXSO 0xC1 // exit secured OTP
|
||||
#define FLASH_CMD_RDSCUR 0x2B // read security register
|
||||
#define FLASH_CMD_WRSCUR 0x2F // write security register
|
||||
#elif FLASH_MXIC_MX25L8073E
|
||||
#define FLASH_CMD_WREN 0x06 //write enable
|
||||
#define FLASH_CMD_WRDI 0x04 //write disable
|
||||
#define FLASH_CMD_WRSR 0x01 //write status register
|
||||
#define FLASH_CMD_RDID 0x9F //read idenfication
|
||||
#define FLASH_CMD_RDSR 0x05 //read status register
|
||||
#define FLASH_CMD_READ 0x03 //read data
|
||||
#define FLASH_CMD_FREAD 0x0B //fast read data
|
||||
#define FLASH_CMD_RDSFDP 0x5A //Read SFDP
|
||||
#define FLASH_CMD_RES 0xAB //Read Electronic ID
|
||||
#define FLASH_CMD_REMS 0x90 //Read Electronic Manufacturer & Device ID
|
||||
#define FLASH_CMD_DREAD 0x3B //Double Output Mode command
|
||||
#define FLASH_CMD_SE 0x20 //Sector Erase
|
||||
#define FLASH_CMD_BE 0x52 //Block Erase
|
||||
#define FLASH_CMD_CE 0x60 //Chip Erase(or 0xC7)
|
||||
#define FLASH_CMD_PP 0x02 //Page Program
|
||||
#define FLASH_CMD_DP 0xB9 //Deep Power Down
|
||||
#define FLASH_CMD_RDP 0xAB //Release from Deep Power-Down
|
||||
#define FLASH_CMD_2READ 0xBB // 2 x I/O read command
|
||||
#define FLASH_CMD_4READ 0xEB // 4 x I/O read command
|
||||
#define FLASH_CMD_QREAD 0x6B // 1I / 4O read command
|
||||
#define FLASH_CMD_4PP 0x38 //quad page program
|
||||
#define FLASH_CMD_FF 0xFF //Release Read Enhanced
|
||||
#define FLASH_CMD_REMS2 0xEF // read ID for 2x I/O mode
|
||||
#define FLASH_CMD_REMS4 0xDF // read ID for 4x I/O mode
|
||||
#define FLASH_CMD_ENSO 0xB1 // enter secured OTP
|
||||
#define FLASH_CMD_EXSO 0xC1 // exit secured OTP
|
||||
#define FLASH_CMD_RDSCUR 0x2B // read security register
|
||||
#define FLASH_CMD_WRSCUR 0x2F // write security register
|
||||
#else
|
||||
#define FLASH_CMD_WREN 0x06 //write enable
|
||||
#define FLASH_CMD_WRDI 0x04 //write disable
|
||||
#define FLASH_CMD_WRSR 0x01 //write status register
|
||||
#define FLASH_CMD_RDID 0x9F //read idenfication
|
||||
#define FLASH_CMD_RDSR 0x05 //read status register
|
||||
#define FLASH_CMD_READ 0x03 //read data
|
||||
#define FLASH_CMD_FREAD 0x0B //fast read data
|
||||
#define FLASH_CMD_RDSFDP 0x5A //Read SFDP
|
||||
#define FLASH_CMD_RES 0xAB //Read Electronic ID
|
||||
#define FLASH_CMD_REMS 0x90 //Read Electronic Manufacturer & Device ID
|
||||
#define FLASH_CMD_DREAD 0x3B //Double Output Mode command
|
||||
#define FLASH_CMD_SE 0x20 //Sector Erase
|
||||
#define FLASH_CMD_BE 0x52 //Block Erase
|
||||
#define FLASH_CMD_CE 0x60 //Chip Erase(or 0xC7)
|
||||
#define FLASH_CMD_PP 0x02 //Page Program
|
||||
#define FLASH_CMD_DP 0xB9 //Deep Power Down
|
||||
#define FLASH_CMD_RDP 0xAB //Release from Deep Power-Down
|
||||
#define FLASH_CMD_2READ 0xBB // 2 x I/O read command
|
||||
#define FLASH_CMD_4READ 0xEB // 4 x I/O read command
|
||||
#define FLASH_CMD_QREAD 0x6B // 1I / 4O read command
|
||||
#define FLASH_CMD_4PP 0x38 //quad page program
|
||||
#define FLASH_CMD_FF 0xFF //Release Read Enhanced
|
||||
#define FLASH_CMD_REMS2 0xEF // read ID for 2x I/O mode
|
||||
#define FLASH_CMD_REMS4 0xDF // read ID for 4x I/O mode
|
||||
#define FLASH_CMD_ENSO 0xB1 // enter secured OTP
|
||||
#define FLASH_CMD_EXSO 0xC1 // exit secured OTP
|
||||
#define FLASH_CMD_RDSCUR 0x2B // read security register
|
||||
#define FLASH_CMD_WRSCUR 0x2F // write security register
|
||||
#endif //#if FLASH_MXIC_MX25L4006E
|
||||
#endif
|
||||
// ============================
|
||||
|
||||
// ===== Flash Parameter Definition =====
|
||||
//#if FLASH_MICRON_N25Q512A
|
||||
#if 0
|
||||
#define FLASH_RD_2IO_EN 1
|
||||
#define FLASH_RD_2O_EN 1
|
||||
#define FLASH_RD_4IO_EN 1
|
||||
#define FLASH_RD_4O_EN 1
|
||||
#define FLASH_WR_2IO_EN 1
|
||||
#define FLASH_WR_2O_EN 1
|
||||
#define FLASH_WR_4IO_EN 1
|
||||
#define FLASH_WR_4O_EN 1
|
||||
#endif
|
||||
#define FLASH_DM_CYCLE_2O 0x08 // 1-1-2
|
||||
#define FLASH_DM_CYCLE_2IO 0x04 // 1-2-2
|
||||
#define FLASH_DM_CYCLE_4O 0x08 // 1-1-4
|
||||
#define FLASH_DM_CYCLE_4IO 0x08 // 1-4-4
|
||||
#define FLASH_VLD_DUAL_CMDS (BIT_WR_BLOCKING | BIT_RD_DUAL_I)// 1-1-2
|
||||
#define FLASH_VLD_QUAD_CMDS (BIT_WR_BLOCKING | BIT_RD_QUAD_IO)// 1-4-4
|
||||
#define FLASH_VLD_QUAD_CMDS2 (BIT_WR_BLOCKING | BIT_RD_QUAD_O)// 1-1-4
|
||||
|
||||
|
||||
//#endif
|
||||
|
||||
#if 0
|
||||
#if FLASH_MXIC_MX25L4006E
|
||||
#define FLASH_RD_2IO_EN 1
|
||||
#define FLASH_RD_2O_EN 0
|
||||
#define FLASH_RD_4IO_EN 1
|
||||
#define FLASH_RD_4O_EN 0
|
||||
#define FLASH_WR_2IO_EN 1
|
||||
#define FLASH_WR_2O_EN 0
|
||||
#define FLASH_WR_4IO_EN 1
|
||||
#define FLASH_WR_4O_EN 0
|
||||
#define FLASH_DM_CYCLE_2O 0x04 // 1-1-2
|
||||
#define FLASH_DM_CYCLE_2IO 0x08 // 1-2-2
|
||||
#define FLASH_DM_CYCLE_4O 0x04 // 1-1-4
|
||||
#define FLASH_DM_CYCLE_4IO 0x08 // 1-4-4
|
||||
#define FLASH_VLD_DUAL_CMDS (BIT_WR_BLOCKING | BIT_WR_DUAL_II | BIT_RD_DUAL_IO)
|
||||
#define FLASH_VLD_QUAD_CMDS (BIT_WR_BLOCKING | BIT_WR_QUAD_II | BIT_RD_QUAD_IO)
|
||||
|
||||
#elif FLASH_MXIC_MX25L8073E //This flash model is just for prototype, if you want to use it,
|
||||
//the code MUST be rechecked according to the flash spec.
|
||||
#define FLASH_RD_2IO_EN 1
|
||||
#define FLASH_RD_2O_EN 0
|
||||
#define FLASH_RD_4IO_EN 1
|
||||
#define FLASH_RD_4O_EN 0
|
||||
#define FLASH_WR_2IO_EN 1
|
||||
#define FLASH_WR_2O_EN 0
|
||||
#define FLASH_WR_4IO_EN 1
|
||||
#define FLASH_WR_4O_EN 0
|
||||
|
||||
#define FLASH_DM_CYCLE_2O 0x08
|
||||
#define FLASH_DM_CYCLE_2IO 0x04
|
||||
#define FLASH_DM_CYCLE_4O 0x08
|
||||
#define FLASH_DM_CYCLE_4IO 0x04
|
||||
|
||||
#define FLASH_VLD_DUAL_CMDS (BIT_WR_BLOCKING | BIT_RD_DUAL_IO)
|
||||
#define FLASH_VLD_QUAD_CMDS (BIT_WR_BLOCKING | BIT_WR_QUAD_II | BIT_RD_QUAD_IO)
|
||||
#else
|
||||
#define FLASH_RD_2IO_EN 1
|
||||
#define FLASH_RD_2O_EN 0
|
||||
#define FLASH_RD_4IO_EN 1
|
||||
#define FLASH_RD_4O_EN 0
|
||||
#define FLASH_WR_2IO_EN 1
|
||||
#define FLASH_WR_2O_EN 0
|
||||
#define FLASH_WR_4IO_EN 1
|
||||
#define FLASH_WR_4O_EN 0
|
||||
|
||||
#define FLASH_DM_CYCLE_2O 0x08
|
||||
#define FLASH_DM_CYCLE_2IO 0x04
|
||||
#define FLASH_DM_CYCLE_4O 0x08
|
||||
#define FLASH_DM_CYCLE_4IO 0x04
|
||||
|
||||
#define FLASH_VLD_DUAL_CMDS (BIT_WR_BLOCKING | BIT_RD_DUAL_IO)
|
||||
#define FLASH_VLD_QUAD_CMDS (BIT_WR_BLOCKING | BIT_WR_QUAD_II | BIT_RD_QUAD_IO)
|
||||
#endif
|
||||
#endif
|
||||
#if 0
|
||||
//======================================================
|
||||
// Function prototype
|
||||
BOOLEAN SpicFlashInitRtl8195A(uint8_t SpicBitMode);
|
||||
|
||||
_LONG_CALL_
|
||||
extern void SpicLoadInitParaFromClockRtl8195A(uint8_t CpuClkMode, uint8_t BaudRate, PSPIC_INIT_PARA pSpicInitPara);
|
||||
|
||||
// spi-flash controller initialization
|
||||
_LONG_CALL_
|
||||
extern void SpicInitRtl8195A(uint8_t InitBaudRate, uint8_t SpicBitMode);
|
||||
|
||||
// wait sr[0] = 0, wait transmission done
|
||||
_LONG_CALL_
|
||||
extern void SpicWaitBusyDoneRtl8195A(void);
|
||||
|
||||
// wait spi-flash status register[0] = 0
|
||||
//_LONG_CALL_
|
||||
//extern void SpicWaitWipDoneRtl8195A(SPIC_INIT_PARA SpicInitPara);
|
||||
#endif
|
||||
|
||||
//======================================================
|
||||
// ROM Function prototype
|
||||
_LONG_CALL_ void SpiFlashAppV02(IN void *Data);
|
||||
_LONG_CALL_ROM_ void SpicInitRtl8195AV02(IN uint8_t InitBaudRate,IN uint8_t SpicBitMode);
|
||||
|
||||
_LONG_CALL_ROM_ void SpicEraseFlashRtl8195AV02(void);
|
||||
|
||||
_LONG_CALL_ROM_ void SpicLoadInitParaFromClockRtl8195AV02(IN uint8_t CpuClkMode,IN uint8_t BaudRate,IN PSPIC_INIT_PARA pSpicInitPara);
|
||||
|
||||
|
||||
void SpicBlockEraseFlashRtl8195A(IN uint32_t Address);
|
||||
void SpicSectorEraseFlashRtl8195A(IN uint32_t Address);
|
||||
void SpicDieEraseFlashRtl8195A(IN uint32_t Address);
|
||||
void SpicWriteProtectFlashRtl8195A(IN uint32_t Protect);
|
||||
void SpicWaitWipDoneRefinedRtl8195A(IN SPIC_INIT_PARA SpicInitPara);
|
||||
void SpicWaitOperationDoneRtl8195A(IN SPIC_INIT_PARA SpicInitPara);
|
||||
void SpicRxCmdRefinedRtl8195A(IN uint8_t cmd,IN SPIC_INIT_PARA SpicInitPara);
|
||||
uint8_t SpicGetFlashStatusRefinedRtl8195A(IN SPIC_INIT_PARA SpicInitPara);
|
||||
void SpicInitRefinedRtl8195A(IN uint8_t InitBaudRate, IN uint8_t SpicBitMode);
|
||||
uint32_t SpicWaitWipRtl8195A(void); // IN SPIC_INIT_PARA SpicInitPara);
|
||||
uint32_t SpicOneBitCalibrationRtl8195A(IN uint8_t SysCpuClk);
|
||||
void SpicDisableRtl8195A(void);
|
||||
void SpicDeepPowerDownFlashRtl8195A(void);
|
||||
void SpicUserProgramRtl8195A(IN uint8_t * data, IN SPIC_INIT_PARA SpicInitPara, IN uint32_t addr, IN uint32_t * LengthInfo);
|
||||
void SpicUserReadRtl8195A(IN uint32_t Length, IN uint32_t addr, IN uint8_t * data, IN uint8_t BitMode);
|
||||
void SpicUserReadFourByteRtl8195A(IN uint32_t Length, IN uint32_t addr, IN uint32_t * data, IN uint8_t BitMode);
|
||||
void SpicReadIDRtl8195A(void);
|
||||
void SpicSetFlashStatusRefinedRtl8195A(IN uint32_t data, IN SPIC_INIT_PARA SpicInitPara);
|
||||
void SpicSetExtendAddrRtl8195A(IN uint32_t data, IN SPIC_INIT_PARA SpicInitPara);
|
||||
uint8_t SpicGetExtendAddrRtl8195A(IN SPIC_INIT_PARA SpicInitPara);
|
||||
#if SPIC_CALIBRATION_IN_NVM
|
||||
void SpicNVMCalLoad(uint8_t BitMode, uint8_t CpuClk);
|
||||
void SpicNVMCalLoadAll(void);
|
||||
void SpicNVMCalStore(uint8_t BitMode, uint8_t CpuClk);
|
||||
#endif // #if SPIC_CALIBRATION_IN_NVM
|
||||
|
||||
#endif //_HAL_SPIFLASH__
|
||||
File diff suppressed because it is too large
Load diff
689
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_ssi.c
Normal file
689
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_ssi.c
Normal file
|
|
@ -0,0 +1,689 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#include "rtl8195a.h"
|
||||
#include "hal_ssi.h"
|
||||
|
||||
#ifdef CONFIG_SOC_PS_EN
|
||||
|
||||
const HAL_GDMA_CHNL Ssi2_TX_GDMA_Chnl_Option[] = {
|
||||
{0,4,GDMA0_CHANNEL4_IRQ,0},
|
||||
{0,5,GDMA0_CHANNEL5_IRQ,0},
|
||||
{0,3,GDMA0_CHANNEL3_IRQ,0},
|
||||
{0,0,GDMA0_CHANNEL0_IRQ,0},
|
||||
{0,1,GDMA0_CHANNEL1_IRQ,0},
|
||||
{0,2,GDMA0_CHANNEL2_IRQ,0},
|
||||
|
||||
{0xff,0,0,0} // end
|
||||
};
|
||||
|
||||
const HAL_GDMA_CHNL Ssi2_RX_GDMA_Chnl_Option[] = {
|
||||
{1,4,GDMA1_CHANNEL4_IRQ,0},
|
||||
{1,5,GDMA1_CHANNEL5_IRQ,0},
|
||||
{1,3,GDMA1_CHANNEL3_IRQ,0},
|
||||
{1,0,GDMA1_CHANNEL0_IRQ,0},
|
||||
{1,1,GDMA1_CHANNEL1_IRQ,0},
|
||||
{1,2,GDMA1_CHANNEL2_IRQ,0},
|
||||
|
||||
{0xff,0,0,0} // end
|
||||
};
|
||||
|
||||
const HAL_GDMA_CHNL Ssi_MultiBlk_GDMA_Chnl_Option[] = {
|
||||
{0,4,GDMA0_CHANNEL4_IRQ,0},
|
||||
{0,5,GDMA0_CHANNEL5_IRQ,0},
|
||||
{1,4,GDMA1_CHANNEL4_IRQ,0},
|
||||
{1,5,GDMA1_CHANNEL5_IRQ,0},
|
||||
{0xff,0,0,0} // end
|
||||
};
|
||||
|
||||
//TODO: Load default Setting: It should be loaded from external setting file.
|
||||
const DW_SSI_DEFAULT_SETTING SpiDefaultSetting =
|
||||
{
|
||||
.RxCompCallback = NULL,
|
||||
.RxCompCbPara = NULL,
|
||||
.RxData = NULL,
|
||||
.TxCompCallback = NULL,
|
||||
.TxCompCbPara = NULL,
|
||||
.TxData = NULL,
|
||||
.DmaRxDataLevel = 7, // RX FIFO stored bytes > (DMARDLR(7) + 1) then trigger DMA transfer
|
||||
.DmaTxDataLevel = 48, // TX FIFO free space > (FIFO_SPACE(64)-DMATDLR(48)) then trigger DMA transfer
|
||||
.InterruptPriority = 10,
|
||||
.RxLength = 0,
|
||||
.RxLengthRemainder = 0,
|
||||
.RxThresholdLevel = 7, // if number of entries in th RX FIFO >= (RxThresholdLevel+1), RX interrupt asserted
|
||||
.TxLength = 0,
|
||||
.TxThresholdLevel = 8, // if number of entries in th TX FIFO <= TxThresholdLevel, TX interrupt asserted
|
||||
.SlaveSelectEnable = 0,
|
||||
.ClockDivider = SSI_CLK_SPI0_2/1000000, // SCLK=1M
|
||||
.DataFrameNumber = 0,
|
||||
.ControlFrameSize = CFS_1_BIT,
|
||||
.DataFrameFormat = FRF_MOTOROLA_SPI,
|
||||
.DataFrameSize = DFS_8_BITS,
|
||||
.DmaControl = 0, // default DMA is disable
|
||||
.InterruptMask = 0x0,
|
||||
.MicrowireDirection = MW_DIRECTION_MASTER_TO_SLAVE,
|
||||
.MicrowireHandshaking = MW_HANDSHAKE_DISABLE,
|
||||
.MicrowireTransferMode = MW_TMOD_NONSEQUENTIAL,
|
||||
.SclkPhase = SCPH_TOGGLES_AT_START,
|
||||
.SclkPolarity = SCPOL_INACTIVE_IS_HIGH,
|
||||
.SlaveOutputEnable = SLV_TXD_ENABLE, // Slave
|
||||
.TransferMode = TMOD_TR,
|
||||
.TransferMechanism = SSI_DTM_INTERRUPT
|
||||
};
|
||||
|
||||
extern HAL_Status HalSsiInitRtl8195a_Patch(void *Adaptor);
|
||||
extern HAL_Status HalSsiPinmuxEnableRtl8195a_Patch(void *Adaptor);
|
||||
extern HAL_Status HalSsiPinmuxDisableRtl8195a(void *Adaptor);
|
||||
extern HAL_Status HalSsiDeInitRtl8195a(void * Adapter);
|
||||
extern HAL_Status HalSsiClockOffRtl8195a(void * Adapter);
|
||||
extern HAL_Status HalSsiClockOnRtl8195a(void * Adapter);
|
||||
extern HAL_Status HalSsiIntReadRtl8195a(void *Adapter, void *RxData, uint32_t Length);
|
||||
extern HAL_Status HalSsiIntWriteRtl8195a(void *Adapter, uint8_t *pTxData, uint32_t Length);
|
||||
extern HAL_Status HalSsiEnterCriticalRtl8195a(void * Data);
|
||||
extern HAL_Status HalSsiExitCriticalRtl8195a(void * Data);
|
||||
extern HAL_Status HalSsiIsTimeoutRtl8195a(uint32_t StartCount, uint32_t TimeoutCnt);
|
||||
extern HAL_Status HalSsiStopRecvRtl8195a(void * Data);
|
||||
extern HAL_Status HalSsiSetFormatRtl8195a(void * Adaptor);
|
||||
extern void HalSsiSetSclkRtl8195a(void *Adapter, uint32_t ClkRate);
|
||||
#ifdef CONFIG_GDMA_EN
|
||||
extern void HalSsiDmaInitRtl8195a(void *Adapter);
|
||||
#endif
|
||||
|
||||
void HalSsiOpInit(void *Adaptor)
|
||||
{
|
||||
PHAL_SSI_OP pHalSsiOp = (PHAL_SSI_OP) Adaptor;
|
||||
|
||||
// pHalSsiOp->HalSsiPinmuxEnable = HalSsiPinmuxEnableRtl8195a;
|
||||
#if CONFIG_CHIP_E_CUT
|
||||
pHalSsiOp->HalSsiPinmuxEnable = HalSsiPinmuxEnableRtl8195a_V04;
|
||||
pHalSsiOp->HalSsiPinmuxDisable = HalSsiPinmuxDisableRtl8195a_V04;
|
||||
#else
|
||||
pHalSsiOp->HalSsiPinmuxEnable = HalSsiPinmuxEnableRtl8195a_Patch;
|
||||
pHalSsiOp->HalSsiPinmuxDisable = HalSsiPinmuxDisableRtl8195a;
|
||||
#endif
|
||||
|
||||
pHalSsiOp->HalSsiEnable = HalSsiEnableRtl8195a;
|
||||
pHalSsiOp->HalSsiDisable = HalSsiDisableRtl8195a;
|
||||
// pHalSsiOp->HalSsiInit = HalSsiInitRtl8195a;
|
||||
#if CONFIG_CHIP_E_CUT
|
||||
pHalSsiOp->HalSsiInit = HalSsiInitRtl8195a_V04;
|
||||
#else
|
||||
pHalSsiOp->HalSsiInit = HalSsiInitRtl8195a_Patch;
|
||||
#endif
|
||||
pHalSsiOp->HalSsiSetSclkPolarity = HalSsiSetSclkPolarityRtl8195a;
|
||||
pHalSsiOp->HalSsiSetSclkPhase = HalSsiSetSclkPhaseRtl8195a;
|
||||
pHalSsiOp->HalSsiWrite = HalSsiWriteRtl8195a;
|
||||
pHalSsiOp->HalSsiRead = HalSsiReadRtl8195a;
|
||||
pHalSsiOp->HalSsiGetRxFifoLevel = HalSsiGetRxFifoLevelRtl8195a;
|
||||
pHalSsiOp->HalSsiGetTxFifoLevel = HalSsiGetTxFifoLevelRtl8195a;
|
||||
pHalSsiOp->HalSsiGetStatus = HalSsiGetStatusRtl8195a;
|
||||
pHalSsiOp->HalSsiGetInterruptStatus = HalSsiGetInterruptStatusRtl8195a;
|
||||
pHalSsiOp->HalSsiLoadSetting = HalSsiLoadSettingRtl8195a;
|
||||
pHalSsiOp->HalSsiSetInterruptMask = HalSsiSetInterruptMaskRtl8195a;
|
||||
pHalSsiOp->HalSsiGetInterruptMask = HalSsiGetInterruptMaskRtl8195a;
|
||||
pHalSsiOp->HalSsiSetDeviceRole = HalSsiSetDeviceRoleRtl8195a;
|
||||
pHalSsiOp->HalSsiWriteable = HalSsiWriteableRtl8195a;
|
||||
pHalSsiOp->HalSsiReadable = HalSsiReadableRtl8195a;
|
||||
pHalSsiOp->HalSsiBusy = HalSsiBusyRtl8195a;
|
||||
pHalSsiOp->HalSsiInterruptEnable = HalSsiInterruptEnableRtl8195a;
|
||||
pHalSsiOp->HalSsiInterruptDisable = HalSsiInterruptDisableRtl8195a;
|
||||
// pHalSsiOp->HalSsiReadInterrupt = HalSsiReadInterruptRtl8195a;
|
||||
#if CONFIG_CHIP_E_CUT
|
||||
pHalSsiOp->HalSsiReadInterrupt = HalSsiIntReadRtl8195a_V04;
|
||||
#else
|
||||
pHalSsiOp->HalSsiReadInterrupt = HalSsiIntReadRtl8195a;
|
||||
#endif
|
||||
pHalSsiOp->HalSsiSetRxFifoThresholdLevel = HalSsiSetRxFifoThresholdLevelRtl8195a;
|
||||
pHalSsiOp->HalSsiSetTxFifoThresholdLevel = HalSsiSetTxFifoThresholdLevelRtl8195a;
|
||||
// pHalSsiOp->HalSsiWriteInterrupt = HalSsiWriteInterruptRtl8195a;
|
||||
#if CONFIG_CHIP_E_CUT
|
||||
pHalSsiOp->HalSsiWriteInterrupt = HalSsiIntWriteRtl8195a_V04;
|
||||
#else
|
||||
pHalSsiOp->HalSsiWriteInterrupt = HalSsiIntWriteRtl8195a;
|
||||
#endif
|
||||
pHalSsiOp->HalSsiGetRawInterruptStatus = HalSsiGetRawInterruptStatusRtl8195a;
|
||||
pHalSsiOp->HalSsiGetSlaveEnableRegister = HalSsiGetSlaveEnableRegisterRtl8195a;
|
||||
pHalSsiOp->HalSsiSetSlaveEnableRegister = HalSsiSetSlaveEnableRegisterRtl8195a;
|
||||
}
|
||||
|
||||
|
||||
#ifdef CONFIG_GDMA_EN
|
||||
HAL_Status
|
||||
HalSsiTxMultiBlkChnl(
|
||||
IN PHAL_SSI_ADAPTOR pHalSsiAdapter
|
||||
)
|
||||
{
|
||||
PHAL_GDMA_ADAPTER pHalGdmaAdapter;
|
||||
PSSI_DMA_CONFIG pDmaConfig;
|
||||
HAL_GDMA_CHNL *pgdma_chnl;
|
||||
|
||||
pDmaConfig = &pHalSsiAdapter->DmaConfig;
|
||||
pHalGdmaAdapter = (PHAL_GDMA_ADAPTER)pDmaConfig->pTxHalGdmaAdapter;
|
||||
|
||||
if((pHalSsiAdapter->HaveTxChannel == 1) && (pHalGdmaAdapter->ChNum != 4) && (pHalGdmaAdapter->ChNum != 5)){
|
||||
HalSsiTxGdmaDeInit(pHalSsiAdapter);
|
||||
}
|
||||
if(pHalSsiAdapter->HaveTxChannel == 0){
|
||||
pgdma_chnl = HalGdmaChnlAlloc((HAL_GDMA_CHNL*)Ssi_MultiBlk_GDMA_Chnl_Option);
|
||||
if (pgdma_chnl == NULL) {
|
||||
DBG_SSI_ERR("No Available DMA channel\n");
|
||||
return HAL_BUSY;
|
||||
}
|
||||
else {
|
||||
pHalGdmaAdapter->GdmaIndex = pgdma_chnl->GdmaIndx;
|
||||
pHalGdmaAdapter->ChNum = pgdma_chnl->GdmaChnl;
|
||||
pHalGdmaAdapter->ChEn = 0x0101 << pgdma_chnl->GdmaChnl;
|
||||
pDmaConfig->TxGdmaIrqHandle.IrqNum = pgdma_chnl->IrqNum;
|
||||
pHalSsiAdapter->HaveTxChannel = 1;
|
||||
InterruptRegister(&pDmaConfig->TxGdmaIrqHandle);
|
||||
InterruptEn(&pDmaConfig->TxGdmaIrqHandle);
|
||||
}
|
||||
HalSsiDmaInit(pHalSsiAdapter);
|
||||
}
|
||||
DBG_SSI_INFO("TX GDMA Index = %x, Channel = %x\n",pHalGdmaAdapter->GdmaIndex,pHalGdmaAdapter->ChNum);
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
HAL_Status
|
||||
HalSsiTxSingleBlkChnl(
|
||||
IN PHAL_SSI_ADAPTOR pHalSsiAdapter
|
||||
)
|
||||
{
|
||||
PHAL_GDMA_ADAPTER pHalGdmaAdapter;
|
||||
PSSI_DMA_CONFIG pDmaConfig;
|
||||
HAL_GDMA_CHNL *pgdma_chnl;
|
||||
|
||||
pDmaConfig = &pHalSsiAdapter->DmaConfig;
|
||||
pHalGdmaAdapter = (PHAL_GDMA_ADAPTER)pDmaConfig->pTxHalGdmaAdapter;
|
||||
|
||||
if(pHalSsiAdapter->HaveTxChannel == 0){
|
||||
if (HalGdmaChnlRegister(pHalGdmaAdapter->GdmaIndex, pHalGdmaAdapter->ChNum) != HAL_OK) {
|
||||
// The default GDMA Channel is not available, try others
|
||||
if (pHalSsiAdapter->Index == 2) {
|
||||
// SSI2 TX Only can use GDMA 0
|
||||
pgdma_chnl = HalGdmaChnlAlloc((HAL_GDMA_CHNL*)Ssi2_TX_GDMA_Chnl_Option);
|
||||
}
|
||||
else {
|
||||
pgdma_chnl = HalGdmaChnlAlloc(NULL);
|
||||
}
|
||||
|
||||
if (pgdma_chnl == NULL) {
|
||||
DBG_SSI_ERR("No Available DMA channel\n");
|
||||
return HAL_BUSY;
|
||||
}
|
||||
else {
|
||||
pHalGdmaAdapter->GdmaIndex = pgdma_chnl->GdmaIndx;
|
||||
pHalGdmaAdapter->ChNum = pgdma_chnl->GdmaChnl;
|
||||
pHalGdmaAdapter->ChEn = 0x0101 << pgdma_chnl->GdmaChnl;
|
||||
pDmaConfig->TxGdmaIrqHandle.IrqNum = pgdma_chnl->IrqNum;
|
||||
pHalSsiAdapter->HaveTxChannel = 1;
|
||||
}
|
||||
}
|
||||
else{
|
||||
pHalSsiAdapter->HaveTxChannel = 1;
|
||||
}
|
||||
InterruptRegister(&pDmaConfig->TxGdmaIrqHandle);
|
||||
InterruptEn(&pDmaConfig->TxGdmaIrqHandle);
|
||||
DBG_SSI_INFO("TX GDMA Index = %x, Channle number = %x\n",pHalGdmaAdapter->GdmaIndex,pHalGdmaAdapter->ChNum);
|
||||
HalSsiDmaInit(pHalSsiAdapter);
|
||||
}
|
||||
|
||||
return HAL_OK;
|
||||
|
||||
}
|
||||
|
||||
HAL_Status
|
||||
HalSsiTxGdmaInit(
|
||||
IN PHAL_SSI_OP pHalSsiOp,
|
||||
IN PHAL_SSI_ADAPTOR pHalSsiAdapter
|
||||
)
|
||||
{
|
||||
|
||||
if ((NULL == pHalSsiOp) || (NULL == pHalSsiAdapter)) {
|
||||
return HAL_ERR_PARA;
|
||||
}
|
||||
|
||||
// Load default setting
|
||||
#if CONFIG_CHIP_E_CUT
|
||||
HalSsiTxGdmaLoadDefRtl8195a_V04((void*)pHalSsiAdapter);
|
||||
#else
|
||||
HalSsiTxGdmaLoadDefRtl8195a((void*)pHalSsiAdapter);
|
||||
#endif
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
void
|
||||
HalSsiTxGdmaDeInit(
|
||||
IN PHAL_SSI_ADAPTOR pHalSsiAdapter
|
||||
)
|
||||
{
|
||||
PSSI_DMA_CONFIG pDmaConfig;
|
||||
PHAL_GDMA_ADAPTER pHalGdmaAdapter;
|
||||
HAL_GDMA_CHNL GdmaChnl;
|
||||
|
||||
if (NULL == pHalSsiAdapter) {
|
||||
return;
|
||||
}
|
||||
|
||||
pDmaConfig = &pHalSsiAdapter->DmaConfig;
|
||||
|
||||
pHalGdmaAdapter = (PHAL_GDMA_ADAPTER)pDmaConfig->pTxHalGdmaAdapter;
|
||||
GdmaChnl.GdmaIndx = pHalGdmaAdapter->GdmaIndex;
|
||||
GdmaChnl.GdmaChnl = pHalGdmaAdapter->ChNum;
|
||||
GdmaChnl.IrqNum = pDmaConfig->TxGdmaIrqHandle.IrqNum;
|
||||
HalGdmaChnlFree(&GdmaChnl);
|
||||
pHalSsiAdapter->HaveTxChannel = 0;
|
||||
}
|
||||
|
||||
|
||||
HAL_Status
|
||||
HalSsiDmaSend(
|
||||
IN void *Adapter, // PHAL_SSI_ADAPTOR
|
||||
IN uint8_t *pTxData, ///< Rx buffer
|
||||
IN uint32_t Length // buffer length
|
||||
)
|
||||
{
|
||||
PHAL_SSI_ADAPTOR pHalSsiAdapter = (PHAL_SSI_ADAPTOR) Adapter;
|
||||
PSSI_DMA_CONFIG pDmaConfig;
|
||||
PHAL_GDMA_ADAPTER pHalGdmaAdapter;
|
||||
PHAL_GDMA_OP pHalGdmaOp;
|
||||
|
||||
pDmaConfig = &pHalSsiAdapter->DmaConfig;
|
||||
pHalGdmaAdapter = (PHAL_GDMA_ADAPTER)pDmaConfig->pTxHalGdmaAdapter;
|
||||
|
||||
#if CONFIG_CHIP_E_CUT
|
||||
HalSsiDmaSendRtl8195a_V04(pHalSsiAdapter,pTxData,Length);
|
||||
#else
|
||||
HalSsiDmaSendRtl8195a(pHalSsiAdapter,pTxData,Length);
|
||||
#endif
|
||||
if (pHalGdmaAdapter->GdmaCtl.BlockSize > MAX_DMA_BLOCK_SIZE) {
|
||||
// Maximum Data Length is 4092*16
|
||||
#if CONFIG_CHIP_E_CUT
|
||||
HalSsiDmaSendMultiBlockRtl8195a_V04(pHalSsiAdapter, pTxData, pHalGdmaAdapter->GdmaCtl.BlockSize);
|
||||
#else
|
||||
HalSsiDmaSendMultiBlockRtl8195a(pHalSsiAdapter, pTxData, pHalGdmaAdapter->GdmaCtl.BlockSize);
|
||||
#endif
|
||||
HalSsiTxMultiBlkChnl(pHalSsiAdapter);
|
||||
}
|
||||
else{
|
||||
pHalGdmaAdapter->ChSar= (uint32_t)pTxData;
|
||||
HalSsiTxSingleBlkChnl(pHalSsiAdapter);
|
||||
pHalGdmaAdapter->Rsvd4to7 = 0;
|
||||
pHalGdmaAdapter->Llpctrl = 0;
|
||||
pHalGdmaAdapter->GdmaCtl.LlpSrcEn = 0;
|
||||
pHalGdmaAdapter->GdmaCtl.LlpDstEn = 0;
|
||||
pHalGdmaAdapter->GdmaCfg.ReloadDst = 0;
|
||||
pHalGdmaAdapter->GdmaCfg.ReloadSrc = 0;
|
||||
}
|
||||
|
||||
// Enable GDMA for TX
|
||||
pHalGdmaOp = (PHAL_GDMA_OP)pDmaConfig->pHalGdmaOp;
|
||||
pHalGdmaOp->HalGdmaOnOff((void*)(pHalGdmaAdapter));
|
||||
pHalGdmaOp->HalGdmaChIsrEnAndDis((void*)(pHalGdmaAdapter));
|
||||
|
||||
if(pHalGdmaAdapter->Llpctrl)
|
||||
pHalGdmaOp->HalGdmaChBlockSeting((void*)(pHalGdmaAdapter));
|
||||
else
|
||||
pHalGdmaOp->HalGdmaChSeting((void*)(pHalGdmaAdapter));
|
||||
pHalGdmaOp->HalGdmaChEn((void*)(pHalGdmaAdapter));
|
||||
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
|
||||
HAL_Status
|
||||
HalSsiRxMultiBlkChnl(
|
||||
IN PHAL_SSI_ADAPTOR pHalSsiAdapter
|
||||
)
|
||||
{
|
||||
PHAL_GDMA_ADAPTER pHalGdmaAdapter;
|
||||
PSSI_DMA_CONFIG pDmaConfig;
|
||||
HAL_GDMA_CHNL *pgdma_chnl;
|
||||
|
||||
pDmaConfig = &pHalSsiAdapter->DmaConfig;
|
||||
pHalGdmaAdapter = (PHAL_GDMA_ADAPTER)pDmaConfig->pRxHalGdmaAdapter;
|
||||
|
||||
if((pHalSsiAdapter->HaveRxChannel == 1) && (pHalGdmaAdapter->ChNum != 4) && (pHalGdmaAdapter->ChNum != 5)){
|
||||
HalSsiRxGdmaDeInit(pHalSsiAdapter);
|
||||
}
|
||||
if(pHalSsiAdapter->HaveRxChannel == 0){
|
||||
pgdma_chnl = HalGdmaChnlAlloc((HAL_GDMA_CHNL*)Ssi_MultiBlk_GDMA_Chnl_Option);
|
||||
if (pgdma_chnl == NULL) {
|
||||
DBG_SSI_ERR("No Available DMA channel\n");
|
||||
return HAL_BUSY;
|
||||
}
|
||||
else {
|
||||
pHalGdmaAdapter->GdmaIndex = pgdma_chnl->GdmaIndx;
|
||||
pHalGdmaAdapter->ChNum = pgdma_chnl->GdmaChnl;
|
||||
pHalGdmaAdapter->ChEn = 0x0101 << pgdma_chnl->GdmaChnl;
|
||||
pDmaConfig->RxGdmaIrqHandle.IrqNum = pgdma_chnl->IrqNum;
|
||||
pHalSsiAdapter->HaveRxChannel = 1;
|
||||
InterruptRegister(&pDmaConfig->RxGdmaIrqHandle);
|
||||
InterruptEn(&pDmaConfig->RxGdmaIrqHandle);
|
||||
}
|
||||
HalSsiDmaInit(pHalSsiAdapter);
|
||||
}
|
||||
DBG_SSI_INFO("RX GDMA index = %x, Channel = %x\n",pHalGdmaAdapter->GdmaIndex,pHalGdmaAdapter->ChNum);
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
HAL_Status
|
||||
HalSsiRxSingleBlkChnl(
|
||||
IN PHAL_SSI_ADAPTOR pHalSsiAdapter
|
||||
)
|
||||
{
|
||||
PHAL_GDMA_ADAPTER pHalGdmaAdapter;
|
||||
PSSI_DMA_CONFIG pDmaConfig;
|
||||
HAL_GDMA_CHNL *pgdma_chnl;
|
||||
|
||||
pDmaConfig = &pHalSsiAdapter->DmaConfig;
|
||||
pHalGdmaAdapter = (PHAL_GDMA_ADAPTER)pDmaConfig->pRxHalGdmaAdapter;
|
||||
|
||||
if(pHalSsiAdapter->HaveRxChannel == 0){
|
||||
if (HalGdmaChnlRegister(pHalGdmaAdapter->GdmaIndex, pHalGdmaAdapter->ChNum) != HAL_OK) {
|
||||
// The default GDMA Channel is not available, try others
|
||||
if (pHalSsiAdapter->Index == 2) {
|
||||
// SSI2 RX Only can use GDMA 1
|
||||
pgdma_chnl = HalGdmaChnlAlloc((HAL_GDMA_CHNL*)Ssi2_RX_GDMA_Chnl_Option);
|
||||
}
|
||||
else {
|
||||
pgdma_chnl = HalGdmaChnlAlloc(NULL);
|
||||
}
|
||||
|
||||
if (pgdma_chnl == NULL) {
|
||||
DBG_SSI_ERR("No Available DMA channel\n");
|
||||
return HAL_BUSY;
|
||||
}
|
||||
else {
|
||||
pHalGdmaAdapter->GdmaIndex = pgdma_chnl->GdmaIndx;
|
||||
pHalGdmaAdapter->ChNum = pgdma_chnl->GdmaChnl;
|
||||
pHalGdmaAdapter->ChEn = 0x0101 << pgdma_chnl->GdmaChnl;
|
||||
pDmaConfig->RxGdmaIrqHandle.IrqNum = pgdma_chnl->IrqNum;
|
||||
pHalSsiAdapter->HaveRxChannel = 1;
|
||||
}
|
||||
}
|
||||
else{
|
||||
pHalSsiAdapter->HaveRxChannel = 1;
|
||||
}
|
||||
InterruptRegister(&pDmaConfig->RxGdmaIrqHandle);
|
||||
InterruptEn(&pDmaConfig->RxGdmaIrqHandle);
|
||||
DBG_SSI_INFO("RX GDMA Index = %x, Channle number = %x\n",pHalGdmaAdapter->GdmaIndex,pHalGdmaAdapter->ChNum);
|
||||
HalSsiDmaInit(pHalSsiAdapter);
|
||||
}
|
||||
return HAL_OK;
|
||||
|
||||
}
|
||||
|
||||
HAL_Status
|
||||
HalSsiRxGdmaInit(
|
||||
IN PHAL_SSI_OP pHalSsiOp,
|
||||
IN PHAL_SSI_ADAPTOR pHalSsiAdapter
|
||||
)
|
||||
{
|
||||
|
||||
if ((NULL == pHalSsiOp) || (NULL == pHalSsiAdapter)) {
|
||||
return HAL_ERR_PARA;
|
||||
}
|
||||
|
||||
// Load default setting
|
||||
#if CONFIG_CHIP_E_CUT
|
||||
HalSsiRxGdmaLoadDefRtl8195a_V04((void*)pHalSsiAdapter);
|
||||
#else
|
||||
HalSsiRxGdmaLoadDefRtl8195a((void*)pHalSsiAdapter);
|
||||
#endif
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
void
|
||||
HalSsiRxGdmaDeInit(
|
||||
IN PHAL_SSI_ADAPTOR pHalSsiAdapter
|
||||
)
|
||||
{
|
||||
PSSI_DMA_CONFIG pDmaConfig;
|
||||
PHAL_GDMA_ADAPTER pHalGdmaAdapter;
|
||||
HAL_GDMA_CHNL GdmaChnl;
|
||||
|
||||
if (NULL == pHalSsiAdapter) {
|
||||
return;
|
||||
}
|
||||
|
||||
pDmaConfig = &pHalSsiAdapter->DmaConfig;
|
||||
|
||||
pHalGdmaAdapter = (PHAL_GDMA_ADAPTER)pDmaConfig->pRxHalGdmaAdapter;
|
||||
GdmaChnl.GdmaIndx = pHalGdmaAdapter->GdmaIndex;
|
||||
GdmaChnl.GdmaChnl = pHalGdmaAdapter->ChNum;
|
||||
GdmaChnl.IrqNum = pDmaConfig->RxGdmaIrqHandle.IrqNum;
|
||||
HalGdmaChnlFree(&GdmaChnl);
|
||||
pHalSsiAdapter->HaveRxChannel = 0;
|
||||
}
|
||||
|
||||
HAL_Status
|
||||
HalSsiDmaRecv(
|
||||
IN void *Adapter, // PHAL_SSI_ADAPTOR
|
||||
IN uint8_t *pRxData, ///< Rx buffer
|
||||
IN uint32_t Length // buffer length
|
||||
)
|
||||
{
|
||||
PHAL_SSI_ADAPTOR pHalSsiAdapter = (PHAL_SSI_ADAPTOR) Adapter;
|
||||
PSSI_DMA_CONFIG pDmaConfig;
|
||||
PHAL_GDMA_ADAPTER pHalGdmaAdapter;
|
||||
PHAL_GDMA_OP pHalGdmaOp;
|
||||
|
||||
pDmaConfig = &pHalSsiAdapter->DmaConfig;
|
||||
pHalGdmaAdapter = (PHAL_GDMA_ADAPTER)pDmaConfig->pRxHalGdmaAdapter;
|
||||
|
||||
#if CONFIG_CHIP_E_CUT
|
||||
HalSsiDmaRecvRtl8195a_V04(pHalSsiAdapter,pRxData,Length);
|
||||
#else
|
||||
HalSsiDmaRecvRtl8195a(pHalSsiAdapter,pRxData,Length);
|
||||
#endif
|
||||
|
||||
if (pHalGdmaAdapter->GdmaCtl.BlockSize > MAX_DMA_BLOCK_SIZE) {
|
||||
// Maximum Data Length is 4092*16
|
||||
#if CONFIG_CHIP_E_CUT
|
||||
HalSsiDmaRecvMultiBlockRtl8195a_V04(pHalSsiAdapter, pRxData, pHalGdmaAdapter->GdmaCtl.BlockSize);
|
||||
#else
|
||||
HalSsiDmaRecvMultiBlockRtl8195a(pHalSsiAdapter, pRxData, pHalGdmaAdapter->GdmaCtl.BlockSize);
|
||||
#endif
|
||||
HalSsiRxMultiBlkChnl(pHalSsiAdapter);
|
||||
}
|
||||
else{
|
||||
pHalGdmaAdapter->ChDar = (uint32_t)pRxData;
|
||||
HalSsiRxSingleBlkChnl(pHalSsiAdapter);
|
||||
pHalGdmaAdapter->Rsvd4to7 = 0;
|
||||
pHalGdmaAdapter->Llpctrl = 0;
|
||||
pHalGdmaAdapter->GdmaCtl.LlpSrcEn = 0;
|
||||
pHalGdmaAdapter->GdmaCtl.LlpDstEn = 0;
|
||||
pHalGdmaAdapter->GdmaCfg.ReloadDst = 0;
|
||||
pHalGdmaAdapter->GdmaCfg.ReloadSrc = 0;
|
||||
|
||||
}
|
||||
|
||||
// Enable GDMA for RX
|
||||
pHalGdmaOp = (PHAL_GDMA_OP)pDmaConfig->pHalGdmaOp;
|
||||
pHalGdmaOp->HalGdmaOnOff((void*)(pHalGdmaAdapter));
|
||||
pHalGdmaOp->HalGdmaChIsrEnAndDis((void*)(pHalGdmaAdapter));
|
||||
|
||||
if(pHalGdmaAdapter->Llpctrl)
|
||||
pHalGdmaOp->HalGdmaChBlockSeting((void*)(pHalGdmaAdapter));
|
||||
else
|
||||
pHalGdmaOp->HalGdmaChSeting((void*)(pHalGdmaAdapter));
|
||||
pHalGdmaOp->HalGdmaChEn((void*)(pHalGdmaAdapter));
|
||||
|
||||
return HAL_OK;
|
||||
|
||||
}
|
||||
|
||||
#endif // end of "#ifdef CONFIG_GDMA_EN"
|
||||
|
||||
HAL_Status
|
||||
HalSsiInit(void *Data)
|
||||
{
|
||||
HAL_Status ret;
|
||||
PHAL_SSI_ADAPTOR pHalSsiAdapter = (PHAL_SSI_ADAPTOR) Data;
|
||||
uint32_t Function = SPI0;
|
||||
uint8_t PinmuxSelect;
|
||||
uint8_t Index;
|
||||
|
||||
PinmuxSelect = pHalSsiAdapter->PinmuxSelect;
|
||||
Index = pHalSsiAdapter->Index;
|
||||
switch (Index){
|
||||
case 0:
|
||||
Function = SPI0;
|
||||
break;
|
||||
case 1:
|
||||
Function = SPI1;
|
||||
break;
|
||||
case 2:
|
||||
Function = SPI2;
|
||||
break;
|
||||
default:
|
||||
DBG_SSI_ERR("Invalid SPI Index.\n");
|
||||
break;
|
||||
}
|
||||
|
||||
ret = FunctionChk(Function, (uint32_t)PinmuxSelect);
|
||||
if(ret == _FALSE){
|
||||
DBG_SSI_ERR("Invalid Pinmux Setting.\n");
|
||||
return HAL_ERR_PARA;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SOC_PS_MODULE
|
||||
REG_POWER_STATE SsiPwrState;
|
||||
#endif
|
||||
#if CONFIG_CHIP_E_CUT
|
||||
ret = HalSsiInitRtl8195a_V04(pHalSsiAdapter);
|
||||
#else
|
||||
ret = HalSsiInitRtl8195a_Patch(pHalSsiAdapter);
|
||||
#endif
|
||||
#ifdef CONFIG_SOC_PS_MODULE
|
||||
if(ret == HAL_OK) {
|
||||
// To register a new peripheral device power state
|
||||
SsiPwrState.FuncIdx = SPI0+ pHalSsiAdapter->Index;
|
||||
SsiPwrState.PwrState = ACT;
|
||||
RegPowerState(SsiPwrState);
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HAL_Status
|
||||
HalSsiDeInit(void *Data)
|
||||
{
|
||||
HAL_Status ret;
|
||||
PHAL_SSI_ADAPTOR pHalSsiAdapter = (PHAL_SSI_ADAPTOR) Data;
|
||||
#ifdef CONFIG_SOC_PS_MODULE
|
||||
REG_POWER_STATE SsiPwrState;
|
||||
uint8_t HardwareState;
|
||||
|
||||
SsiPwrState.FuncIdx= SPI0+ pHalSsiAdapter->Index;
|
||||
QueryRegPwrState(SsiPwrState.FuncIdx, &(SsiPwrState.PwrState), &HardwareState);
|
||||
|
||||
if(SsiPwrState.PwrState != HardwareState){
|
||||
DBG_SSI_ERR("Registered State is not the Hardware State");
|
||||
return HAL_ERR_UNKNOWN;
|
||||
}
|
||||
else{
|
||||
if((SsiPwrState.PwrState != INACT) && (SsiPwrState.PwrState !=ACT)){
|
||||
DBG_SSI_INFO("Return to ACT state before DeInit");
|
||||
HalSsiEnable(pHalSsiAdapter);
|
||||
QueryRegPwrState(SsiPwrState.FuncIdx, &(SsiPwrState.PwrState), &HardwareState);
|
||||
}
|
||||
if(SsiPwrState.PwrState == ACT){
|
||||
SsiPwrState.PwrState = INACT;
|
||||
RegPowerState(SsiPwrState);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if CONFIG_CHIP_E_CUT
|
||||
ret = HalSsiDeInitRtl8195a_V04(pHalSsiAdapter);
|
||||
#else
|
||||
ret = HalSsiDeInitRtl8195a(pHalSsiAdapter);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
HAL_Status
|
||||
HalSsiEnable(void *Data)
|
||||
{
|
||||
HAL_Status ret;
|
||||
PHAL_SSI_ADAPTOR pHalSsiAdapter = (PHAL_SSI_ADAPTOR) Data;
|
||||
#ifdef CONFIG_SOC_PS_MODULE
|
||||
REG_POWER_STATE SsiPwrState;
|
||||
#endif
|
||||
#if CONFIG_CHIP_E_CUT
|
||||
ret = HalSsiClockOnRtl8195a_V04(pHalSsiAdapter);
|
||||
#else
|
||||
ret = HalSsiClockOnRtl8195a(pHalSsiAdapter);
|
||||
#endif
|
||||
#ifdef CONFIG_SOC_PS_MODULE
|
||||
if(ret == HAL_OK) {
|
||||
// To register a new peripheral device power state
|
||||
SsiPwrState.FuncIdx = SPI0+ pHalSsiAdapter->Index;
|
||||
SsiPwrState.PwrState = ACT;
|
||||
RegPowerState(SsiPwrState);
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HAL_Status
|
||||
HalSsiDisable(void *Data)
|
||||
{
|
||||
HAL_Status ret;
|
||||
PHAL_SSI_ADAPTOR pHalSsiAdapter = (PHAL_SSI_ADAPTOR) Data;
|
||||
#ifdef CONFIG_SOC_PS_MODULE
|
||||
REG_POWER_STATE SsiPwrState;
|
||||
#endif
|
||||
#if CONFIG_CHIP_E_CUT
|
||||
ret = HalSsiClockOffRtl8195a_V04(pHalSsiAdapter);
|
||||
#else
|
||||
ret = HalSsiClockOffRtl8195a(pHalSsiAdapter);
|
||||
#endif
|
||||
#ifdef CONFIG_SOC_PS_MODULE
|
||||
if(ret == HAL_OK) {
|
||||
// To register a new peripheral device power state
|
||||
SsiPwrState.FuncIdx = SPI0+ pHalSsiAdapter->Index;
|
||||
SsiPwrState.PwrState = SLPCG;
|
||||
RegPowerState(SsiPwrState);
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HAL_Status HalSsiEnterCritical(void *Data)
|
||||
{
|
||||
return HalSsiEnterCriticalRtl8195a(Data);
|
||||
}
|
||||
|
||||
HAL_Status HalSsiExitCritical(void *Data)
|
||||
{
|
||||
return HalSsiExitCriticalRtl8195a(Data);
|
||||
}
|
||||
|
||||
HAL_Status HalSsiTimeout(uint32_t StartCount, uint32_t TimeoutCnt)
|
||||
{
|
||||
return HalSsiIsTimeoutRtl8195a(StartCount,TimeoutCnt);
|
||||
}
|
||||
|
||||
HAL_Status HalSsiStopRecv(void * Data)
|
||||
{
|
||||
return HalSsiStopRecvRtl8195a(Data);
|
||||
}
|
||||
|
||||
HAL_Status HalSsiSetFormat(void * Data)
|
||||
{
|
||||
return HalSsiSetFormatRtl8195a(Data);
|
||||
}
|
||||
|
||||
#endif // CONFIG_SOC_PS_EN
|
||||
336
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_ssi.h
Normal file
336
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_ssi.h
Normal file
|
|
@ -0,0 +1,336 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _HAL_SSI_H_
|
||||
#define _HAL_SSI_H_
|
||||
|
||||
#include "rtl8195a_ssi.h"
|
||||
|
||||
/**
|
||||
* LOG Configurations
|
||||
*/
|
||||
|
||||
extern uint32_t SSI_DBG_CONFIG;
|
||||
extern uint8_t SPI0_IS_AS_SLAVE;
|
||||
|
||||
|
||||
#define SSI_DBG_ENTRANCE(...) do {\
|
||||
if (unlikely(SSI_DBG_CONFIG & DBG_TYPE_ENTRANCE)) \
|
||||
DBG_SSI_INFO(IDENT_FOUR_SPACE ANSI_COLOR_GREEN __VA_ARGS__ ANSI_COLOR_RESET); \
|
||||
}while(0)
|
||||
|
||||
#define SSI_DBG_INIT(...) do {\
|
||||
if (unlikely(SSI_DBG_CONFIG & DBG_TYPE_INIT)) \
|
||||
DBG_SSI_INFO(IDENT_FOUR_SPACE __VA_ARGS__); \
|
||||
}while(0)
|
||||
|
||||
#define SSI_DBG_INIT_V(...) do {\
|
||||
if (unlikely(SSI_DBG_CONFIG & DBG_TYPE_INIT_V)) \
|
||||
DBG_SSI_INFO(IDENT_FOUR_SPACE __VA_ARGS__); \
|
||||
}while(0)
|
||||
|
||||
#define SSI_DBG_INIT_VV(...) do {\
|
||||
if (unlikely(SSI_DBG_CONFIG & DBG_TYPE_INIT_VV)) \
|
||||
DBG_SSI_INFO(IDENT_FOUR_SPACE __VA_ARGS__); \
|
||||
}while(0)
|
||||
|
||||
#define SSI_DBG_PINMUX(...) do {\
|
||||
if (unlikely(SSI_DBG_CONFIG & DBG_TYPE_PINMUX)) \
|
||||
DBG_SSI_INFO(IDENT_FOUR_SPACE __VA_ARGS__); \
|
||||
}while(0)
|
||||
|
||||
#define SSI_DBG_ENDIS(...) do {\
|
||||
if (unlikely(SSI_DBG_CONFIG & DBG_TYPE_ENDIS)) \
|
||||
DBG_SSI_INFO(IDENT_FOUR_SPACE __VA_ARGS__); \
|
||||
}while(0)
|
||||
|
||||
#define SSI_DBG_INT(...) do {\
|
||||
if (unlikely(SSI_DBG_CONFIG & DBG_TYPE_INT)) \
|
||||
DBG_SSI_INFO(IDENT_FOUR_SPACE __VA_ARGS__); \
|
||||
}while(0)
|
||||
|
||||
#define SSI_DBG_INT_V(...) do {\
|
||||
if (unlikely(SSI_DBG_CONFIG & DBG_TYPE_INT_V)) \
|
||||
DBG_SSI_INFO(IDENT_FOUR_SPACE __VA_ARGS__); \
|
||||
}while(0)
|
||||
|
||||
#define SSI_DBG_INT_HNDLR(...) do {\
|
||||
if (unlikely(SSI_DBG_CONFIG & DBG_TYPE_INT_HNDLR)) \
|
||||
DBG_SSI_INFO(IDENT_FOUR_SPACE __VA_ARGS__); \
|
||||
}while(0)
|
||||
|
||||
#define SSI_DBG_INT_READ(...) do {\
|
||||
if (unlikely(SSI_DBG_CONFIG & DBG_TYPE_INT_READ)) \
|
||||
DBG_SSI_INFO(IDENT_FOUR_SPACE __VA_ARGS__); \
|
||||
}while(0)
|
||||
|
||||
#define SSI_DBG_INT_WRITE(...) do {\
|
||||
if (unlikely(SSI_DBG_CONFIG & DBG_TYPE_INT_WRITE)) \
|
||||
DBG_SSI_INFO(IDENT_FOUR_SPACE __VA_ARGS__); \
|
||||
}while(0)
|
||||
|
||||
#define SSI_DBG_STATUS(...) do {\
|
||||
if (unlikely(SSI_DBG_CONFIG & DBG_TYPE_STATUS)) \
|
||||
DBG_SSI_INFO(IDENT_FOUR_SPACE __VA_ARGS__); \
|
||||
}while(0)
|
||||
|
||||
#define SSI_DBG_FIFO(...) do {\
|
||||
if (unlikely(SSI_DBG_CONFIG & DBG_TYPE_FIFO)) \
|
||||
DBG_SSI_INFO(IDENT_FOUR_SPACE __VA_ARGS__); \
|
||||
}while(0)
|
||||
|
||||
#define SSI_DBG_READ(...) do {\
|
||||
if (unlikely(SSI_DBG_CONFIG & DBG_TYPE_READ)) \
|
||||
DBG_SSI_INFO(IDENT_FOUR_SPACE __VA_ARGS__); \
|
||||
}while(0)
|
||||
|
||||
#define SSI_DBG_WRITE(...) do {\
|
||||
if (unlikely(SSI_DBG_CONFIG & DBG_TYPE_WRITE)) \
|
||||
DBG_SSI_INFO(IDENT_FOUR_SPACE __VA_ARGS__); \
|
||||
}while(0)
|
||||
|
||||
#define SSI_DBG_SLV_CTRL(...) do {\
|
||||
if (unlikely(SSI_DBG_CONFIG & DBG_TYPE_SLV_CTRL)) \
|
||||
DBG_SSI_INFO(IDENT_FOUR_SPACE __VA_ARGS__); \
|
||||
}while(0)
|
||||
|
||||
typedef enum _SSI_DBG_TYPE_LIST_ {
|
||||
DBG_TYPE_ENTRANCE = 1 << 0,
|
||||
DBG_TYPE_INIT = 1 << 1,
|
||||
DBG_TYPE_INIT_V = 1 << 2,
|
||||
DBG_TYPE_INIT_VV = 1 << 3,
|
||||
DBG_TYPE_PINMUX = 1 << 4,
|
||||
DBG_TYPE_ENDIS = 1 << 5,
|
||||
DBG_TYPE_INT = 1 << 6,
|
||||
DBG_TYPE_INT_V = 1 << 7,
|
||||
DBG_TYPE_INT_HNDLR = 1 << 8,
|
||||
DBG_TYPE_INT_READ = 1 << 9,
|
||||
DBG_TYPE_INT_WRITE = 1 << 10,
|
||||
DBG_TYPE_STATUS = 1 << 11,
|
||||
DBG_TYPE_FIFO = 1 << 12,
|
||||
DBG_TYPE_READ = 1 << 13,
|
||||
DBG_TYPE_WRITE = 1 << 14,
|
||||
DBG_TYPE_SLV_CTRL = 1 << 15
|
||||
} SSI_DBG_TYPE_LIST, *PSSI_DBG_TYPE_LIST;
|
||||
|
||||
typedef struct _SSI_DMA_CONFIG_ {
|
||||
void *pHalGdmaOp;
|
||||
void *pTxHalGdmaAdapter;
|
||||
void *pRxHalGdmaAdapter;
|
||||
uint8_t RxDmaBurstSize;
|
||||
uint8_t TxDmaBurstSize;
|
||||
uint8_t RxDmaEnable;
|
||||
uint8_t TxDmaEnable;
|
||||
IRQ_HANDLE RxGdmaIrqHandle;
|
||||
IRQ_HANDLE TxGdmaIrqHandle;
|
||||
}SSI_DMA_CONFIG, *PSSI_DMA_CONFIG;
|
||||
|
||||
#ifdef CONFIG_GDMA_EN
|
||||
typedef struct _HAL_SSI_DMA_MULTIBLK_ {
|
||||
volatile GDMA_CH_LLI_ELE GdmaChLli[16];
|
||||
struct GDMA_CH_LLI Lli[16];
|
||||
struct BLOCK_SIZE_LIST BlockSizeList[16];
|
||||
}SSI_DMA_MULTIBLK, *PSSI_DMA_MULTIBLK;
|
||||
#endif
|
||||
/**
|
||||
* DesignWare SSI Configurations
|
||||
*/
|
||||
typedef struct _HAL_SSI_ADAPTOR_ {
|
||||
SSI_DMA_CONFIG DmaConfig;
|
||||
IRQ_HANDLE IrqHandle;
|
||||
//
|
||||
void (*RxCompCallback)(void *Para);
|
||||
void *RxCompCbPara;
|
||||
void *RxData;
|
||||
void (*TxCompCallback)(void *Para);
|
||||
void *TxCompCbPara;
|
||||
void *TxData;
|
||||
uint32_t DmaRxDataLevel;
|
||||
uint32_t DmaTxDataLevel;
|
||||
uint32_t InterruptPriority;
|
||||
uint32_t RxLength;
|
||||
uint32_t RxLengthRemainder;
|
||||
uint32_t RxThresholdLevel;
|
||||
uint32_t TxLength;
|
||||
uint32_t TxThresholdLevel;
|
||||
uint32_t SlaveSelectEnable;
|
||||
//
|
||||
uint16_t ClockDivider;
|
||||
uint16_t DataFrameNumber;
|
||||
//
|
||||
uint8_t ControlFrameSize;
|
||||
uint8_t DataFrameFormat;
|
||||
uint8_t DataFrameSize;
|
||||
uint8_t DmaControl;
|
||||
uint8_t Index;
|
||||
uint8_t InterruptMask;
|
||||
uint8_t MicrowireDirection;
|
||||
uint8_t MicrowireHandshaking;
|
||||
uint8_t MicrowireTransferMode;
|
||||
uint8_t PinmuxSelect;
|
||||
uint8_t Role;
|
||||
uint8_t SclkPhase;
|
||||
uint8_t SclkPolarity;
|
||||
uint8_t SlaveOutputEnable;
|
||||
uint8_t TransferMode;
|
||||
uint8_t TransferMechanism;
|
||||
|
||||
// Extend
|
||||
uint8_t Reserve;
|
||||
uint8_t HaveTxChannel;
|
||||
uint8_t HaveRxChannel;
|
||||
uint8_t DefaultRxThresholdLevel;
|
||||
#ifdef CONFIG_GDMA_EN
|
||||
SSI_DMA_MULTIBLK DmaTxMultiBlk, DmaRxMultiBlk;
|
||||
#endif
|
||||
uint32_t ReservedDummy;
|
||||
void (*TxIdleCallback)(void *Para);
|
||||
void *TxIdleCbPara;
|
||||
}HAL_SSI_ADAPTOR, *PHAL_SSI_ADAPTOR;
|
||||
|
||||
typedef struct _HAL_SSI_OP_{
|
||||
HAL_Status (*HalSsiPinmuxEnable)(void *Adaptor);
|
||||
HAL_Status (*HalSsiPinmuxDisable)(void *Adaptor);
|
||||
HAL_Status (*HalSsiEnable)(void *Adaptor);
|
||||
HAL_Status (*HalSsiDisable)(void *Adaptor);
|
||||
HAL_Status (*HalSsiInit)(void *Adaptor);
|
||||
HAL_Status (*HalSsiSetSclkPolarity)(void *Adaptor);
|
||||
HAL_Status (*HalSsiSetSclkPhase)(void *Adaptor);
|
||||
HAL_Status (*HalSsiWrite)(void *Adaptor, uint32_t value);
|
||||
HAL_Status (*HalSsiLoadSetting)(void *Adaptor, void *Setting);
|
||||
HAL_Status (*HalSsiSetInterruptMask)(void *Adaptor);
|
||||
HAL_Status (*HalSsiSetDeviceRole)(void *Adaptor, uint32_t Role);
|
||||
HAL_Status (*HalSsiInterruptEnable)(void *Adaptor);
|
||||
HAL_Status (*HalSsiInterruptDisable)(void *Adaptor);
|
||||
HAL_Status (*HalSsiReadInterrupt)(void *Adaptor, void *RxData, uint32_t Length);
|
||||
HAL_Status (*HalSsiSetRxFifoThresholdLevel)(void *Adaptor);
|
||||
HAL_Status (*HalSsiSetTxFifoThresholdLevel)(void *Adaptor);
|
||||
HAL_Status (*HalSsiWriteInterrupt)(void *Adaptor, uint8_t *TxData, uint32_t Length);
|
||||
HAL_Status (*HalSsiSetSlaveEnableRegister)(void *Adaptor, uint32_t SlaveIndex);
|
||||
uint32_t (*HalSsiBusy)(void *Adaptor);
|
||||
uint32_t (*HalSsiReadable)(void *Adaptor);
|
||||
uint32_t (*HalSsiWriteable)(void *Adaptor);
|
||||
uint32_t (*HalSsiGetInterruptMask)(void *Adaptor);
|
||||
uint32_t (*HalSsiGetRxFifoLevel)(void *Adaptor);
|
||||
uint32_t (*HalSsiGetTxFifoLevel)(void *Adaptor);
|
||||
uint32_t (*HalSsiGetStatus)(void *Adaptor);
|
||||
uint32_t (*HalSsiGetInterruptStatus)(void *Adaptor);
|
||||
uint32_t (*HalSsiRead)(void *Adaptor);
|
||||
uint32_t (*HalSsiGetRawInterruptStatus)(void *Adaptor);
|
||||
uint32_t (*HalSsiGetSlaveEnableRegister)(void *Adaptor);
|
||||
}HAL_SSI_OP, *PHAL_SSI_OP;
|
||||
|
||||
typedef struct _DW_SSI_DEFAULT_SETTING_ {
|
||||
void (*RxCompCallback)(void *Para);
|
||||
void *RxCompCbPara;
|
||||
void *RxData;
|
||||
void (*TxCompCallback)(void *Para);
|
||||
void *TxCompCbPara;
|
||||
void *TxData;
|
||||
uint32_t DmaRxDataLevel;
|
||||
uint32_t DmaTxDataLevel;
|
||||
uint32_t InterruptPriority;
|
||||
uint32_t RxLength;
|
||||
uint32_t RxLengthRemainder;
|
||||
uint32_t RxThresholdLevel;
|
||||
uint32_t TxLength;
|
||||
uint32_t TxThresholdLevel;
|
||||
uint32_t SlaveSelectEnable;
|
||||
//
|
||||
uint16_t ClockDivider;
|
||||
uint16_t DataFrameNumber;
|
||||
//
|
||||
uint8_t ControlFrameSize;
|
||||
uint8_t DataFrameFormat;
|
||||
uint8_t DataFrameSize;
|
||||
uint8_t DmaControl;
|
||||
//uint8_t Index;
|
||||
uint8_t InterruptMask;
|
||||
uint8_t MicrowireDirection;
|
||||
uint8_t MicrowireHandshaking;
|
||||
uint8_t MicrowireTransferMode;
|
||||
//uint8_t PinmuxSelect;
|
||||
//uint8_t Role;
|
||||
uint8_t SclkPhase;
|
||||
uint8_t SclkPolarity;
|
||||
uint8_t SlaveOutputEnable;
|
||||
uint8_t TransferMode;
|
||||
uint8_t TransferMechanism;
|
||||
} DW_SSI_DEFAULT_SETTING, *PDW_SSI_DEFAULT_SETTING;
|
||||
|
||||
|
||||
struct spi_s {
|
||||
HAL_SSI_ADAPTOR spi_adp;
|
||||
HAL_SSI_OP spi_op;
|
||||
uint32_t irq_handler;
|
||||
uint32_t irq_id;
|
||||
uint32_t dma_en;
|
||||
uint32_t state;
|
||||
uint8_t sclk;
|
||||
#ifdef CONFIG_GDMA_EN
|
||||
HAL_GDMA_ADAPTER spi_gdma_adp_tx;
|
||||
HAL_GDMA_ADAPTER spi_gdma_adp_rx;
|
||||
#endif
|
||||
uint32_t bus_tx_done_handler;
|
||||
uint32_t bus_tx_done_irq_id;
|
||||
};
|
||||
|
||||
void HalSsiOpInit(void *Adaptor);
|
||||
static __inline__ void HalSsiSetSclk(
|
||||
IN PHAL_SSI_ADAPTOR pHalSsiAdapter,
|
||||
IN uint32_t ClkRate)
|
||||
{
|
||||
HalSsiSetSclkRtl8195a((void*)pHalSsiAdapter, ClkRate);
|
||||
}
|
||||
|
||||
HAL_Status HalSsiInit(void * Data);
|
||||
HAL_Status HalSsiDeInit(void * Data);
|
||||
HAL_Status HalSsiEnable(void * Data);
|
||||
HAL_Status HalSsiDisable(void * Data);
|
||||
HAL_Status HalSsiEnterCritical(void * Data);
|
||||
HAL_Status HalSsiExitCritical(void * Data);
|
||||
HAL_Status HalSsiTimeout(uint32_t StartCount, uint32_t TimeoutCnt);
|
||||
HAL_Status HalSsiStopRecv(void * Data);
|
||||
HAL_Status HalSsiSetFormat(void * Data);
|
||||
#ifdef CONFIG_GDMA_EN
|
||||
HAL_Status HalSsiTxGdmaInit(PHAL_SSI_OP pHalSsiOp, PHAL_SSI_ADAPTOR pHalSsiAdapter);
|
||||
void HalSsiTxGdmaDeInit(PHAL_SSI_ADAPTOR pHalSsiAdapter);
|
||||
HAL_Status HalSsiRxGdmaInit(PHAL_SSI_OP pHalSsiOp, PHAL_SSI_ADAPTOR pHalSsiAdapter);
|
||||
void HalSsiRxGdmaDeInit(PHAL_SSI_ADAPTOR pHalSsiAdapter);
|
||||
HAL_Status HalSsiRxMultiBlkChnl(PHAL_SSI_ADAPTOR pHalSsiAdapter);
|
||||
HAL_Status HalSsiDmaRecv(void * Adapter, uint8_t * pRxData, uint32_t Length);
|
||||
HAL_Status HalSsiDmaSend(void *Adapter, uint8_t *pTxData, uint32_t Length);
|
||||
|
||||
static __inline__ void
|
||||
HalSsiDmaInit(
|
||||
IN PHAL_SSI_ADAPTOR pHalSsiAdapter
|
||||
)
|
||||
{
|
||||
#if CONFIG_CHIP_E_CUT
|
||||
HalSsiDmaInitRtl8195a_V04((void *)pHalSsiAdapter);
|
||||
#else
|
||||
HalSsiDmaInitRtl8195a((void *)pHalSsiAdapter);
|
||||
#endif
|
||||
}
|
||||
/*
|
||||
static __inline__ HAL_Status HalSsiDmaSend(void *Adapter, uint8_t *pTxData, uint32_t Length)
|
||||
{
|
||||
return (HalSsiDmaSendRtl8195a(Adapter, pTxData, Length));
|
||||
}
|
||||
|
||||
static __inline__ HAL_Status HalSsiDmaRecv(void *Adapter, uint8_t *pRxData, uint32_t Length)
|
||||
{
|
||||
return (HalSsiDmaRecvRtl8195a(Adapter, pRxData, Length));
|
||||
}
|
||||
*/
|
||||
|
||||
#endif // end of "#ifdef CONFIG_GDMA_EN"
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
|
||||
#include "rtl8195a.h"
|
||||
|
||||
#ifdef CONFIG_TIMER_EN
|
||||
void
|
||||
HalTimerOpInit_Patch(
|
||||
IN void *Data
|
||||
)
|
||||
{
|
||||
PHAL_TIMER_OP pHalTimerOp = (PHAL_TIMER_OP) Data;
|
||||
|
||||
pHalTimerOp->HalGetTimerId = HalGetTimerIdRtl8195a;
|
||||
#ifdef CONFIG_CHIP_E_CUT
|
||||
pHalTimerOp->HalTimerInit = (BOOL (*)(void*))HalTimerInitRtl8195a_V04;
|
||||
#else
|
||||
pHalTimerOp->HalTimerInit = (BOOL (*)(void*))HalTimerInitRtl8195a_Patch;
|
||||
#endif
|
||||
#if defined(CONFIG_CHIP_C_CUT) || defined(CONFIG_CHIP_E_CUT)
|
||||
pHalTimerOp->HalTimerReadCount = HalTimerReadCountRtl8195aV02;
|
||||
#else
|
||||
pHalTimerOp->HalTimerReadCount = HalTimerReadCountRtl8195a_Patch;
|
||||
#endif
|
||||
pHalTimerOp->HalTimerIrqClear = HalTimerIrqClearRtl8195a;
|
||||
pHalTimerOp->HalTimerDis = HalTimerDisRtl8195a_Patch;
|
||||
pHalTimerOp->HalTimerEn = HalTimerEnRtl8195a_Patch;
|
||||
pHalTimerOp->HalTimerDumpReg = HalTimerDumpRegRtl8195a;
|
||||
}
|
||||
|
||||
#endif // CONFIG_TIMER_EN
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _HAL_TIMER_H_
|
||||
#define _HAL_TIMER_H_
|
||||
#include "basic_types.h"
|
||||
#include "hal_platform.h"
|
||||
#include "rtl8195a_timer.h"
|
||||
|
||||
#define GTIMER_CLK_HZ (32768)
|
||||
#define GTIMER_TICK_US (1000000/GTIMER_CLK_HZ)
|
||||
|
||||
typedef enum _TIMER_MODE_ {
|
||||
FREE_RUN_MODE = 0,
|
||||
USER_DEFINED = 1
|
||||
}TIMER_MODE, *PTIMER_MODE;
|
||||
|
||||
|
||||
typedef struct _TIMER_ADAPTER_ {
|
||||
|
||||
uint32_t TimerLoadValueUs; //+00
|
||||
uint32_t TimerIrqPriority; //+04
|
||||
TIMER_MODE TimerMode; //+08
|
||||
IRQ_HANDLE IrqHandle; //+0c
|
||||
uint8_t TimerId; //+1c?
|
||||
uint8_t IrqDis; //+1d?
|
||||
|
||||
}TIMER_ADAPTER, *PTIMER_ADAPTER;
|
||||
|
||||
|
||||
typedef struct _HAL_TIMER_OP_ {
|
||||
uint32_t (*HalGetTimerId)(uint32_t *TimerId); //+00
|
||||
BOOL (*HalTimerInit)(void *Data); //+04
|
||||
uint32_t (*HalTimerReadCount)(uint32_t TimerId); //+08
|
||||
void (*HalTimerIrqClear)(uint32_t TimerId); //+0c
|
||||
void (*HalTimerDis)(uint32_t TimerId); //+10
|
||||
void (*HalTimerEn)(uint32_t TimerId); //+14
|
||||
void (*HalTimerDumpReg)(uint32_t TimerId); //+18
|
||||
}HAL_TIMER_OP, *PHAL_TIMER_OP;
|
||||
|
||||
#ifdef CONFIG_TIMER_MODULE
|
||||
// This variable declared in ROM code
|
||||
extern HAL_TIMER_OP HalTimerOp;
|
||||
#endif
|
||||
|
||||
void HalTimerOpInit_Patch(
|
||||
IN void *Data
|
||||
);
|
||||
|
||||
|
||||
//======================================================
|
||||
// ROM Function prototype
|
||||
_LONG_CALL_ void HalTimerOpInitV02(IN void *Data);
|
||||
|
||||
#ifndef CONFIG_RELEASE_BUILD_LIBRARIES
|
||||
#define HalTimerOpInit HalTimerOpInit_Patch
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_RELEASE_BUILD_LIBRARIES
|
||||
void HalTimerOpInit(
|
||||
void *Data
|
||||
);
|
||||
|
||||
HAL_Status
|
||||
HalTimerInit(
|
||||
void *Data
|
||||
);
|
||||
|
||||
void
|
||||
HalTimerEnable(
|
||||
uint32_t TimerId
|
||||
);
|
||||
|
||||
void
|
||||
HalTimerDisable(
|
||||
uint32_t TimerId
|
||||
);
|
||||
|
||||
void
|
||||
HalTimerReLoad(
|
||||
uint32_t TimerId,
|
||||
uint32_t LoadUs
|
||||
);
|
||||
|
||||
void
|
||||
HalTimerDeInit(
|
||||
void *Data
|
||||
);
|
||||
#endif // #ifdef CONFIG_RELEASE_BUILD_LIBRARIES
|
||||
#endif
|
||||
1112
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_uart.c
Normal file
1112
Firmware/RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_uart.c
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,257 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _HAL_UART_H_
|
||||
#define _HAL_UART_H_
|
||||
|
||||
#include "rtl8195a_uart.h"
|
||||
|
||||
/**
|
||||
* RUART Configurations
|
||||
*/
|
||||
#define UART_WAIT_FOREVER 0xffffffff
|
||||
|
||||
#define UART_DMA_MBLK_NUM 16 // maximum block number for each DMA transfer, it must <= 16
|
||||
#define UART_DMA_BLOCK_SIZE 4092 // the block size of multiple block DMA, it cann0t over 4095
|
||||
|
||||
typedef struct _HAL_UART_DMA_MULTIBLK_ {
|
||||
volatile GDMA_CH_LLI_ELE GdmaChLli[UART_DMA_MBLK_NUM];
|
||||
struct GDMA_CH_LLI Lli[UART_DMA_MBLK_NUM];
|
||||
struct BLOCK_SIZE_LIST BlockSizeList[UART_DMA_MBLK_NUM];
|
||||
}UART_DMA_MULTIBLK, *PUART_DMA_MULTIBLK;
|
||||
|
||||
typedef struct _UART_DMA_CONFIG_ {
|
||||
uint8_t TxDmaEnable;
|
||||
uint8_t RxDmaEnable;
|
||||
uint8_t TxDmaBurstSize;
|
||||
uint8_t RxDmaBurstSize;
|
||||
void *pHalGdmaOp;
|
||||
void *pTxHalGdmaAdapter;
|
||||
void *pRxHalGdmaAdapter;
|
||||
IRQ_HANDLE TxGdmaIrqHandle;
|
||||
IRQ_HANDLE RxGdmaIrqHandle;
|
||||
#if defined(E_CUT_ROM_DOMAIN) || (!defined(CONFIG_RELEASE_BUILD_LIBRARIES))
|
||||
UART_DMA_MULTIBLK *pTxDmaBlkList; // point to multi-block list
|
||||
UART_DMA_MULTIBLK *pRxDmaBlkList; // point to multi-block list
|
||||
uint8_t TxDmaMBChnl; // is using DMA multiple block channel
|
||||
uint8_t RxDmaMBChnl; // is using DMA multiple block channel
|
||||
#endif
|
||||
}UART_DMA_CONFIG, *PUART_DMA_CONFIG;
|
||||
|
||||
typedef struct _HAL_RUART_ADAPTER_ {
|
||||
uint32_t BaudRate;
|
||||
uint32_t FlowControl;
|
||||
uint32_t FifoControl;
|
||||
uint32_t Interrupts;
|
||||
uint32_t TxCount; // how many byte to TX
|
||||
uint32_t RxCount; // how many bytes to RX
|
||||
uint8_t *pTxBuf;
|
||||
uint8_t *pRxBuf;
|
||||
HAL_UART_State State; // UART state
|
||||
uint8_t Status; // Transfer Status
|
||||
uint8_t Locked; // is UART locked for operation
|
||||
uint8_t UartIndex;
|
||||
uint8_t WordLen; // word length select: 0 -> 7 bits, 1 -> 8 bits
|
||||
uint8_t StopBit; // word length select: 0 -> 1 stop bit, 1 -> 2 stop bit
|
||||
uint8_t Parity; // parity check enable
|
||||
uint8_t ParityType; // parity check type
|
||||
uint8_t StickParity;
|
||||
uint8_t ModemStatus; // the modem status
|
||||
uint8_t DmaEnable;
|
||||
uint8_t TestCaseNumber;
|
||||
uint8_t PinmuxSelect;
|
||||
BOOL PullMode;
|
||||
IRQ_HANDLE IrqHandle;
|
||||
PUART_DMA_CONFIG DmaConfig;
|
||||
void (*ModemStatusInd)(void *pAdapter); // modem status indication interrupt handler
|
||||
void (*TxTDCallback)(void *pAdapter); // User Tx Done callback function
|
||||
void (*RxDRCallback)(void *pAdapter); // User Rx Data ready callback function
|
||||
void (*TxCompCallback)(void *para); // User Tx complete callback function
|
||||
void (*RxCompCallback)(void *para); // User Rx complete callback function
|
||||
void *TxTDCbPara; // the pointer agrument for TxTDCallback
|
||||
void *RxDRCbPara; // the pointer agrument for RxDRCallback
|
||||
void *TxCompCbPara; // the pointer argument for TxCompCbPara
|
||||
void *RxCompCbPara; // the pointer argument for RxCompCallback
|
||||
void (*EnterCritical)(void);
|
||||
void (*ExitCritical)(void);
|
||||
|
||||
#if defined(E_CUT_ROM_DOMAIN) || (!defined(CONFIG_RELEASE_BUILD_LIBRARIES))
|
||||
//1 New member only can be added below: members above must be fixed for ROM code
|
||||
uint32_t *pDefaultBaudRateTbl; // point to the table of pre-defined baud rate
|
||||
uint8_t *pDefaultOvsrRTbl; // point to the table of OVSR for pre-defined baud rate
|
||||
uint16_t *pDefaultDivTbl; // point to the table of DIV for pre-defined baud rate
|
||||
uint8_t *pDefOvsrAdjBitTbl_10; // point to the table of OVSR-Adj bits for 10 bits
|
||||
uint8_t *pDefOvsrAdjBitTbl_9; // point to the table of OVSR-Adj bits for 9 bits
|
||||
uint8_t *pDefOvsrAdjBitTbl_8; // point to the table of OVSR-Adj bits for 8 bits
|
||||
uint16_t *pDefOvsrAdjTbl_10; // point to the table of OVSR-Adj for pre-defined baud rate
|
||||
uint16_t *pDefOvsrAdjTbl_9; // point to the table of OVSR-Adj for pre-defined baud rate
|
||||
uint16_t *pDefOvsrAdjTbl_8; // point to the table of OVSR-Adj for pre-defined baud rate
|
||||
PUART_DMA_MULTIBLK pTxDMAMBlk; // point to the Link List Table of the DMA Multiple Block
|
||||
PUART_DMA_MULTIBLK pRxDMAMBlk; // point to the Link List Table of the DMA Multiple Block
|
||||
uint32_t BaudRateUsing; // Current using Baud-Rate
|
||||
uint8_t WordLenUsing; // Current using Word Length
|
||||
uint8_t ParityUsing; // Current using Parity check
|
||||
uint8_t RTSCtrl; // Software RTS Control
|
||||
|
||||
#if 0//CONFIG_CHIP_E_CUT
|
||||
uint8_t TxState;
|
||||
uint8_t RxState;
|
||||
uint32_t TxInitSize; // how many byte to TX at atart
|
||||
uint32_t RxInitSize; // how many bytes to RX at start
|
||||
|
||||
void (*RuartEnterCritical)(void *para); // enter critical: disable UART interrupt
|
||||
void (*RuartExitCritical)(void *para); // exit critical: re-enable UART interrupt
|
||||
void (*TaskYield)(void *para); // User Task Yield: do a context switch while waitting
|
||||
void *TaskYieldPara; // the agrument (pointer) for TaskYield
|
||||
#endif // #if CONFIG_CHIP_E_CUT
|
||||
#endif
|
||||
}HAL_RUART_ADAPTER, *PHAL_RUART_ADAPTER;
|
||||
|
||||
typedef struct _HAL_RUART_OP_ {
|
||||
void (*HalRuartAdapterLoadDef)(void *pAdp, uint8_t UartIdx); // Load UART adapter default setting
|
||||
void (*HalRuartTxGdmaLoadDef)(void *pAdp, void *pCfg); // Load TX GDMA default setting
|
||||
void (*HalRuartRxGdmaLoadDef)(void *pAdp, void *pCfg); // Load RX GDMA default setting
|
||||
HAL_Status (*HalRuartResetRxFifo)(void *Data);
|
||||
HAL_Status (*HalRuartInit)(void *Data);
|
||||
void (*HalRuartDeInit)(void *Data);
|
||||
HAL_Status (*HalRuartPutC)(void *Data, uint8_t TxData);
|
||||
uint32_t (*HalRuartSend)(void *Data, uint8_t *pTxData, uint32_t Length, uint32_t Timeout);
|
||||
HAL_Status (*HalRuartIntSend)(void *Data, uint8_t *pTxData, uint32_t Length);
|
||||
HAL_Status (*HalRuartDmaSend)(void *Data, uint8_t *pTxData, uint32_t Length);
|
||||
HAL_Status (*HalRuartStopSend)(void *Data);
|
||||
HAL_Status (*HalRuartGetC)(void *Data, uint8_t *pRxByte);
|
||||
uint32_t (*HalRuartRecv)(void *Data, uint8_t *pRxData, uint32_t Length, uint32_t Timeout);
|
||||
HAL_Status (*HalRuartIntRecv)(void *Data, uint8_t *pRxData, uint32_t Length);
|
||||
HAL_Status (*HalRuartDmaRecv)(void *Data, uint8_t *pRxData, uint32_t Length);
|
||||
HAL_Status (*HalRuartStopRecv)(void *Data);
|
||||
uint8_t (*HalRuartGetIMR)(void *Data);
|
||||
void (*HalRuartSetIMR)(void *Data);
|
||||
uint32_t (*HalRuartGetDebugValue)(void *Data, uint32_t DbgSel);
|
||||
void (*HalRuartDmaInit)(void *Data);
|
||||
void (*HalRuartRTSCtrl)(void *Data, BOOLEAN RtsCtrl);
|
||||
void (*HalRuartRegIrq)(void *Data);
|
||||
void (*HalRuartIntEnable)(void *Data);
|
||||
void (*HalRuartIntDisable)(void *Data);
|
||||
}HAL_RUART_OP, *PHAL_RUART_OP;
|
||||
|
||||
typedef struct _RUART_DATA_ {
|
||||
PHAL_RUART_ADAPTER pHalRuartAdapter;
|
||||
BOOL PullMode;
|
||||
uint8_t BinaryData;
|
||||
uint8_t SendBuffer;
|
||||
uint8_t RecvBuffer;
|
||||
}RUART_DATA, *PRUART_DATA;
|
||||
|
||||
typedef struct _RUART_ADAPTER_ {
|
||||
PHAL_RUART_OP pHalRuartOp;
|
||||
PHAL_RUART_ADAPTER pHalRuartAdapter;
|
||||
PUART_DMA_CONFIG pHalRuartDmaCfg;
|
||||
}RUART_ADAPTER, *PRUART_ADAPTER;
|
||||
|
||||
extern void
|
||||
HalRuartOpInit(
|
||||
IN void *Data
|
||||
);
|
||||
|
||||
extern HAL_Status
|
||||
HalRuartTxGdmaInit(
|
||||
PHAL_RUART_ADAPTER pHalRuartAdapter,
|
||||
PUART_DMA_CONFIG pUartGdmaConfig,
|
||||
uint8_t IsMultiBlk
|
||||
);
|
||||
|
||||
extern void
|
||||
HalRuartTxGdmaDeInit(
|
||||
PUART_DMA_CONFIG pUartGdmaConfig
|
||||
);
|
||||
|
||||
extern HAL_Status
|
||||
HalRuartRxGdmaInit(
|
||||
PHAL_RUART_ADAPTER pHalRuartAdapter,
|
||||
PUART_DMA_CONFIG pUartGdmaConfig,
|
||||
uint8_t IsMultiBlk
|
||||
);
|
||||
|
||||
extern void
|
||||
HalRuartRxGdmaDeInit(
|
||||
PUART_DMA_CONFIG pUartGdmaConfig
|
||||
);
|
||||
|
||||
extern HAL_Status
|
||||
HalRuartResetTxFifo(
|
||||
void *Data
|
||||
);
|
||||
|
||||
extern HAL_Status HalRuartResetTRxFifo(IN void *Data);
|
||||
|
||||
extern HAL_Status
|
||||
HalRuartResetRxFifo(
|
||||
IN void *Data
|
||||
);
|
||||
|
||||
extern HAL_Status
|
||||
HalRuartSetBaudRate(
|
||||
IN void *Data
|
||||
);
|
||||
|
||||
extern HAL_Status
|
||||
HalRuartInit(
|
||||
IN void *Data
|
||||
);
|
||||
|
||||
extern void
|
||||
HalRuartDeInit(
|
||||
IN void *Data
|
||||
);
|
||||
|
||||
extern HAL_Status
|
||||
HalRuartDisable(
|
||||
IN void *Data
|
||||
);
|
||||
|
||||
extern HAL_Status
|
||||
HalRuartEnable(
|
||||
IN void *Data
|
||||
);
|
||||
|
||||
HAL_Status
|
||||
HalRuartFlowCtrl(
|
||||
IN void *Data
|
||||
);
|
||||
|
||||
void
|
||||
HalRuartEnterCritical(
|
||||
IN void *Data
|
||||
);
|
||||
|
||||
void
|
||||
HalRuartExitCritical(
|
||||
IN void *Data
|
||||
);
|
||||
|
||||
HAL_Status
|
||||
HalRuartDmaSend(
|
||||
IN void *Data,
|
||||
IN uint8_t *pTxBuf,
|
||||
IN uint32_t Length
|
||||
);
|
||||
|
||||
HAL_Status
|
||||
HalRuartDmaRecv(
|
||||
IN void *Data,
|
||||
IN uint8_t *pRxBuf,
|
||||
IN uint32_t Length
|
||||
);
|
||||
|
||||
extern const HAL_RUART_OP _HalRuartOp;
|
||||
extern HAL_Status RuartLock (PHAL_RUART_ADAPTER pHalRuartAdapter);
|
||||
extern void RuartUnLock (PHAL_RUART_ADAPTER pHalRuartAdapter);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _HAL_USB_H_
|
||||
#define _HAL_USB_H_
|
||||
|
||||
#include "rtl8195a_usb.h"
|
||||
|
||||
#endif //_HAL_USB_H_
|
||||
|
|
@ -0,0 +1,252 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
#ifndef _HAL_UTIL_H_
|
||||
#define _HAL_UTIL_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Simple doubly linked list implementation.
|
||||
*
|
||||
* Some of the internal functions ("__xxx") are useful when
|
||||
* manipulating whole lists rather than single entries, as
|
||||
* sometimes we already know the next/prev entries and we can
|
||||
* generate better code by using them directly rather than
|
||||
* using the generic single-entry routines.
|
||||
*/
|
||||
struct LIST_HEADER {
|
||||
struct LIST_HEADER *Next, *Prev;
|
||||
};
|
||||
|
||||
typedef struct LIST_HEADER _LIST;
|
||||
|
||||
//#define RTL_LIST_HEAD_INIT(name) { &(name), &(name) }
|
||||
|
||||
#define RTL_INIT_LIST_HEAD(ptr) do { \
|
||||
(ptr)->Next = (ptr); (ptr)->Prev = (ptr); \
|
||||
} while (0)
|
||||
|
||||
|
||||
/*
|
||||
* Insert a new entry between two known consecutive entries.
|
||||
*
|
||||
* This is only for internal list manipulation where we know
|
||||
* the prev/next entries already!
|
||||
*/
|
||||
static __inline__ void
|
||||
__List_Add(
|
||||
IN struct LIST_HEADER * New,
|
||||
IN struct LIST_HEADER * Prev,
|
||||
IN struct LIST_HEADER * Next
|
||||
)
|
||||
{
|
||||
Next->Prev = New;
|
||||
New->Next = Next;
|
||||
New->Prev = Prev;
|
||||
Prev->Next = New;
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete a list entry by making the prev/next entries
|
||||
* point to each other.
|
||||
*
|
||||
* This is only for internal list manipulation where we know
|
||||
* the prev/next entries already!
|
||||
*/
|
||||
static __inline__ void
|
||||
__List_Del(
|
||||
IN struct LIST_HEADER * Prev,
|
||||
IN struct LIST_HEADER * Next
|
||||
)
|
||||
{
|
||||
Next->Prev = Prev;
|
||||
Prev->Next = Next;
|
||||
}
|
||||
|
||||
/**
|
||||
* ListDel - deletes entry from list.
|
||||
* @entry: the element to delete from the list.
|
||||
* Note: list_empty on entry does not return true after this, the entry is in an undefined state.
|
||||
*/
|
||||
static __inline__ void
|
||||
ListDel(
|
||||
IN struct LIST_HEADER *Entry
|
||||
)
|
||||
{
|
||||
__List_Del(Entry->Prev, Entry->Next);
|
||||
}
|
||||
|
||||
/**
|
||||
* ListDelInit - deletes entry from list and reinitialize it.
|
||||
* @entry: the element to delete from the list.
|
||||
*/
|
||||
static __inline__ void
|
||||
ListDelInit(
|
||||
IN struct LIST_HEADER *Entry
|
||||
)
|
||||
{
|
||||
__List_Del(Entry->Prev, Entry->Next);
|
||||
RTL_INIT_LIST_HEAD(Entry);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* ListEmpty - tests whether a list is empty
|
||||
* @head: the list to test.
|
||||
*/
|
||||
static __inline__ uint32_t
|
||||
ListEmpty(
|
||||
IN struct LIST_HEADER *Head
|
||||
)
|
||||
{
|
||||
return Head->Next == Head;
|
||||
}
|
||||
|
||||
/**
|
||||
* ListSplice - join two lists
|
||||
* @list: the new list to add.
|
||||
* @head: the place to add it in the first list.
|
||||
*/
|
||||
static __inline__ void
|
||||
ListSplice(
|
||||
IN struct LIST_HEADER *List,
|
||||
IN struct LIST_HEADER *Head
|
||||
)
|
||||
{
|
||||
struct LIST_HEADER *First = List->Next;
|
||||
|
||||
if (First != List) {
|
||||
struct LIST_HEADER *Last = List->Prev;
|
||||
struct LIST_HEADER *At = Head->Next;
|
||||
|
||||
First->Prev = Head;
|
||||
Head->Next = First;
|
||||
|
||||
Last->Next = At;
|
||||
At->Prev = Last;
|
||||
}
|
||||
}
|
||||
|
||||
static __inline__ void
|
||||
ListAdd(
|
||||
IN struct LIST_HEADER *New,
|
||||
IN struct LIST_HEADER *head
|
||||
)
|
||||
{
|
||||
__List_Add(New, head, head->Next);
|
||||
}
|
||||
|
||||
|
||||
static __inline__ void
|
||||
ListAddTail(
|
||||
IN struct LIST_HEADER *New,
|
||||
IN struct LIST_HEADER *head
|
||||
)
|
||||
{
|
||||
__List_Add(New, head->Prev, head);
|
||||
}
|
||||
|
||||
static __inline void
|
||||
RtlInitListhead(
|
||||
IN _LIST *list
|
||||
)
|
||||
{
|
||||
RTL_INIT_LIST_HEAD(list);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
For the following list_xxx operations,
|
||||
caller must guarantee the atomic context.
|
||||
Otherwise, there will be racing condition.
|
||||
*/
|
||||
static __inline uint32_t
|
||||
RtlIsListEmpty(
|
||||
IN _LIST *phead
|
||||
)
|
||||
{
|
||||
|
||||
if (ListEmpty(phead))
|
||||
return _TRUE;
|
||||
else
|
||||
return _FALSE;
|
||||
|
||||
}
|
||||
|
||||
static __inline void
|
||||
RtlListInsertHead(
|
||||
IN _LIST *plist,
|
||||
IN _LIST *phead
|
||||
)
|
||||
{
|
||||
ListAdd(plist, phead);
|
||||
}
|
||||
|
||||
static __inline void
|
||||
RtlListInsertTail(
|
||||
IN _LIST *plist,
|
||||
IN _LIST *phead
|
||||
)
|
||||
{
|
||||
ListAddTail(plist, phead);
|
||||
}
|
||||
|
||||
|
||||
static __inline _LIST
|
||||
*RtlListGetNext(
|
||||
IN _LIST *plist
|
||||
)
|
||||
{
|
||||
return plist->Next;
|
||||
}
|
||||
|
||||
static __inline void
|
||||
RtlListDelete(
|
||||
IN _LIST *plist
|
||||
)
|
||||
{
|
||||
ListDelInit(plist);
|
||||
}
|
||||
|
||||
#define RTL_LIST_CONTAINOR(ptr, type, member) \
|
||||
((type *)((char *)(ptr)-(SIZE_T)(&((type *)0)->member)))
|
||||
|
||||
#ifndef CONTAINER_OF
|
||||
#define CONTAINER_OF(ptr, type, member) \
|
||||
((type *)((char *)(ptr)-(SIZE_T)(&((type *)0)->member)))
|
||||
#endif
|
||||
#if 0
|
||||
#define list_entry(ptr, type, member) \
|
||||
CONTAINER_OF(ptr, type, member)
|
||||
|
||||
#define list_first_entry(ptr, type, member) \
|
||||
list_entry((ptr)->Next, type, member)
|
||||
|
||||
#define list_next_entry(pos, member, type) \
|
||||
list_entry((pos)->member.Next, type, member)
|
||||
|
||||
#define list_for_each_entry(pos, head, member, type) \
|
||||
for (pos = list_first_entry(head, type, member); \
|
||||
&pos->member != (head); \
|
||||
pos = list_next_entry(pos, member, type))
|
||||
#define list_for_each(pos, head) \
|
||||
for (pos = (head)->Next; pos != (head); pos = pos->Next)
|
||||
#endif
|
||||
|
||||
#ifndef BIT
|
||||
#define BIT(x) ( 1 << (x))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //_HAL_UTIL_H_
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _HAL_VECTOR_TABLE_H_
|
||||
#define _HAL_VECTOR_TABLE_H_
|
||||
|
||||
|
||||
|
||||
|
||||
extern _LONG_CALL_ROM_ void
|
||||
VectorTableInitRtl8195A(
|
||||
IN uint32_t StackP
|
||||
);
|
||||
|
||||
extern _LONG_CALL_ROM_ void
|
||||
VectorTableInitForOSRtl8195A(
|
||||
IN void *PortSVC,
|
||||
IN void *PortPendSVH,
|
||||
IN void *PortSysTick
|
||||
);
|
||||
|
||||
extern _LONG_CALL_ROM_ BOOL
|
||||
VectorIrqRegisterRtl8195A(
|
||||
IN PIRQ_HANDLE pIrqHandle
|
||||
);
|
||||
|
||||
extern _LONG_CALL_ROM_ BOOL
|
||||
VectorIrqUnRegisterRtl8195A(
|
||||
IN PIRQ_HANDLE pIrqHandle
|
||||
);
|
||||
|
||||
|
||||
extern _LONG_CALL_ROM_ void
|
||||
VectorIrqEnRtl8195A(
|
||||
IN PIRQ_HANDLE pIrqHandle
|
||||
);
|
||||
|
||||
extern _LONG_CALL_ROM_ void
|
||||
VectorIrqDisRtl8195A(
|
||||
IN PIRQ_HANDLE pIrqHandle
|
||||
);
|
||||
|
||||
|
||||
extern _LONG_CALL_ROM_ void
|
||||
HalPeripheralIntrHandle(void);
|
||||
#endif //_HAL_VECTOR_TABLE_H_
|
||||
|
|
@ -0,0 +1,130 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2015 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#include "rtl8195a.h"
|
||||
#include "build_info.h"
|
||||
#include "PinNames.h"
|
||||
#include "serial_api.h"
|
||||
|
||||
extern void serial_init (serial_t *obj, PinName tx, PinName rx);
|
||||
extern void serial_free (serial_t *obj);
|
||||
extern void serial_baud (serial_t *obj, int baudrate);
|
||||
extern void serial_format (serial_t *obj, int data_bits, SerialParity parity, int stop_bits);
|
||||
extern int main(void);
|
||||
|
||||
void iar_data_init_fw_loader(void);
|
||||
void fw_loader_main(void);// __attribute__ ((weak));
|
||||
|
||||
#pragma section=".image2.start.table1"
|
||||
#pragma section=".fwloader_ram.bss"
|
||||
|
||||
FW_LOADER_START_RAM_FUN_SECTION
|
||||
RAM_START_FUNCTION gFWLoaderEntryFun0 = {fw_loader_main};
|
||||
|
||||
uint8_t* __image4_entry_func__;
|
||||
uint8_t* __image4_validate_code__;
|
||||
uint8_t* __fwloader_bss_start__;
|
||||
uint8_t* __fwloader_bss_end__;
|
||||
|
||||
FW_LOADER_VALID_PATTEN_SECTION const uint8_t RAM_FW_LOADER_VALID_PATTEN[20] = {
|
||||
'R', 'T', 'K', 'W', 'i', 'n', 0x0, 0xff,
|
||||
(FW_VERSION&0xff), ((FW_VERSION >> 8)&0xff),
|
||||
(FW_SUBVERSION&0xff), ((FW_SUBVERSION >> 8)&0xff),
|
||||
(FW_CHIP_ID&0xff), ((FW_CHIP_ID >> 8)&0xff),
|
||||
(FW_CHIP_VER),
|
||||
(FW_BUS_TYPE),
|
||||
(FW_INFO_RSV1),
|
||||
(FW_INFO_RSV2),
|
||||
(FW_INFO_RSV3),
|
||||
(FW_INFO_RSV4)
|
||||
};
|
||||
/**
|
||||
* @brief Main program.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void fw_loader_main(void)
|
||||
{
|
||||
#if defined ( __ICCARM__ )
|
||||
iar_data_init_fw_loader();
|
||||
#endif
|
||||
uint32_t Image2Len, Image2Addr, ImageIndex, SpicBitMode, SpicImageIndex;
|
||||
uint32_t Image2LoadAddr = 0x13000;
|
||||
DBG_8195A("===== Enter FW Loader Image ====\n");
|
||||
|
||||
|
||||
#ifdef BOOTLOADER
|
||||
main();
|
||||
#endif
|
||||
|
||||
IGMAE4:
|
||||
PRAM_START_FUNCTION Image4EntryFun=(PRAM_START_FUNCTION)__image4_entry_func__;
|
||||
|
||||
Image2Len = HAL_READ32(SPI_FLASH_BASE, Image2LoadAddr);
|
||||
Image2Addr = HAL_READ32(SPI_FLASH_BASE, (Image2LoadAddr+0x4));
|
||||
|
||||
DBG_8195A("Flash FW Loader:Addr 0x%x, Len %d, Load to SRAM 0x%x\n", Image2LoadAddr, Image2Len, Image2Addr);
|
||||
|
||||
SpicImageIndex = 0;
|
||||
for (ImageIndex = 0x10 + Image2LoadAddr; ImageIndex < (Image2Len + Image2LoadAddr + 0x10); ImageIndex = ImageIndex + 4) {
|
||||
HAL_WRITE32(Image2Addr, SpicImageIndex,
|
||||
HAL_READ32(SPI_FLASH_BASE, ImageIndex));
|
||||
|
||||
SpicImageIndex += 4;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef CONFIG_SDR_EN
|
||||
uint32_t Image3LoadAddr;
|
||||
uint32_t Image3Len;
|
||||
uint32_t Image3Addr;
|
||||
|
||||
Image3LoadAddr = Image2LoadAddr + Image2Len+0x10;
|
||||
Image3Len = HAL_READ32(SPI_FLASH_BASE, Image3LoadAddr);
|
||||
Image3Addr = HAL_READ32(SPI_FLASH_BASE, Image3LoadAddr + 0x4);
|
||||
|
||||
if( (Image3Len==0xFFFFFFFF) || (Image3Len==0) || (Image3Addr!=0x30000000)){
|
||||
DBG_8195A("No Image3\n\r");
|
||||
}else{
|
||||
DBG_8195A("Image3 length: 0x%x, Image3 Addr: 0x%x\n",Image3Len, Image3Addr);
|
||||
SpicImageIndex = 0;
|
||||
|
||||
for (ImageIndex = 0x10 + Image3LoadAddr;
|
||||
ImageIndex < (Image3Len + Image3LoadAddr + 0x10);
|
||||
ImageIndex = ImageIndex + 4) {
|
||||
HAL_WRITE32(Image3Addr, SpicImageIndex,
|
||||
HAL_READ32(SPI_FLASH_BASE, ImageIndex));
|
||||
|
||||
SpicImageIndex += 4;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//3 3) Jump to image 4
|
||||
DBG_8195A("InfraStart: %p, Img2 Sign %s \n", __image4_entry_func__, (char*)__image4_validate_code__);
|
||||
if (_strcmp((char *)__image4_validate_code__, "RTKWin")) {
|
||||
while (1) {
|
||||
DBG_8195A("Invalid Image4 Signature\n");
|
||||
RtlConsolRom(1000);//each delay is 100us
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef BOOTLOADER
|
||||
deinit_platform_bootloader();
|
||||
#endif
|
||||
Image4EntryFun->RamStartFun();
|
||||
}
|
||||
|
||||
void iar_data_init_fw_loader(void)
|
||||
{
|
||||
__image4_entry_func__ = (uint8_t*)__section_begin(".image2.start.table1");
|
||||
__image4_validate_code__ = __image4_entry_func__+4;//(uint8_t*)__section_begin(".image2.start.table2");
|
||||
__fwloader_bss_start__ = (uint8_t*)__section_begin(".fwloader_ram.bss");
|
||||
__fwloader_bss_end__ = (uint8_t*)__section_end(".fwloader_ram.bss");
|
||||
}
|
||||
|
|
@ -0,0 +1,359 @@
|
|||
#include "rtl8195a.h"
|
||||
|
||||
typedef struct _UART_LOG_BUF_ {
|
||||
uint8_t BufCount; //record the input cmd char number.
|
||||
uint8_t UARTLogBuf[127]; //record the input command.
|
||||
} UART_LOG_BUF, *PUART_LOG_BUF;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct _UART_LOG_CTL_ {
|
||||
uint8_t NewIdx;
|
||||
uint8_t SeeIdx;
|
||||
uint8_t RevdNo;
|
||||
uint8_t EscSTS;
|
||||
uint8_t ExecuteCmd;
|
||||
uint8_t ExecuteEsc;
|
||||
uint8_t BootRdy;
|
||||
uint8_t Resvd;
|
||||
PUART_LOG_BUF pTmpLogBuf;
|
||||
void *pfINPUT;
|
||||
PCOMMAND_TABLE pCmdTbl;
|
||||
uint32_t CmdTblSz;
|
||||
|
||||
uint32_t CRSTS;
|
||||
|
||||
uint8_t (*pHistoryBuf)[127];
|
||||
|
||||
uint32_t TaskRdy;
|
||||
uint32_t Sema;
|
||||
} UART_LOG_CTL, *PUART_LOG_CTL;
|
||||
|
||||
volatile UART_LOG_CTL UartLogCtl;
|
||||
|
||||
volatile UART_LOG_CTL *pUartLogCtl;
|
||||
|
||||
uint8_t *ArgvArray[10];
|
||||
|
||||
UART_LOG_BUF UartLogBuf;
|
||||
|
||||
|
||||
uint8_t UartLogHistoryBuf[5][127];
|
||||
|
||||
extern void
|
||||
SpicLoadInitParaFromClockRtl8195A
|
||||
(
|
||||
IN uint8_t CpuClkMode,
|
||||
IN uint8_t BaudRate,
|
||||
IN PSPIC_INIT_PARA pSpicInitPara
|
||||
);
|
||||
|
||||
void
|
||||
PatchSpicInitRtl8195A
|
||||
(
|
||||
IN uint8_t InitBaudRate,
|
||||
IN uint8_t SpicBitMode
|
||||
)
|
||||
{
|
||||
|
||||
uint32_t Value32;
|
||||
SPIC_INIT_PARA SpicInitPara;
|
||||
|
||||
#ifdef CONFIG_FPGA
|
||||
SpicInitPara.BaudRate = 1;//FPGASpicInitPara.BaudRate;
|
||||
SpicInitPara.RdDummyCyle = 1;//FPGASpicInitPara.RdDummyCyle;
|
||||
SpicInitPara.DelayLine = 0;//FPGASpicInitPara.DelayLine;
|
||||
#else
|
||||
uint8_t CpuClk;
|
||||
CpuClk = (((uint8_t)(HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_CLK_CTRL1) & (0x70))) >> 4);
|
||||
SpicLoadInitParaFromClockRtl8195A(CpuClk, InitBaudRate, &SpicInitPara);
|
||||
#endif
|
||||
// Disable SPI_FLASH User Mode
|
||||
HAL_SPI_WRITE32(REG_SPIC_SSIENR, 0);
|
||||
|
||||
HAL_SPI_WRITE32(REG_SPIC_BAUDR, BIT_SCKDV(InitBaudRate));
|
||||
|
||||
HAL_SPI_WRITE32(REG_SPIC_SER, BIT_SER);
|
||||
|
||||
Value32 = HAL_SPI_READ32(REG_SPIC_AUTO_LENGTH);
|
||||
|
||||
HAL_SPI_WRITE32(REG_SPIC_AUTO_LENGTH,
|
||||
((Value32 & 0xFFFF0000) | BIT_RD_DUMMY_LENGTH(SpicInitPara.RdDummyCyle)));
|
||||
|
||||
HAL_WRITE32(PERI_ON_BASE, REG_PESOC_MEM_CTRL,
|
||||
((HAL_READ32(PERI_ON_BASE, REG_PESOC_MEM_CTRL)&0xFFFFFF00)|
|
||||
SpicInitPara.DelayLine));
|
||||
|
||||
HAL_SPI_WRITE32(REG_SPIC_CTRLR1, BIT_NDF(4));
|
||||
|
||||
switch (SpicBitMode) {
|
||||
case SpicOneBitMode:
|
||||
HAL_SPI_WRITE32(REG_SPIC_CTRLR0,
|
||||
(HAL_SPI_READ32(REG_SPIC_CTRLR0) & (~(BIT_ADDR_CH(3)|BIT_DATA_CH(3)))));
|
||||
break;
|
||||
|
||||
case SpicDualBitMode:
|
||||
HAL_SPI_WRITE32(REG_SPIC_CTRLR0,
|
||||
((HAL_SPI_READ32(REG_SPIC_CTRLR0) & (~(BIT_ADDR_CH(3)|BIT_DATA_CH(3)))) |
|
||||
(BIT_ADDR_CH(1)|BIT_DATA_CH(1))));
|
||||
|
||||
break;
|
||||
|
||||
case SpicQuadBitMode:
|
||||
HAL_SPI_WRITE32(REG_SPIC_CTRLR0,
|
||||
((HAL_SPI_READ32(REG_SPIC_CTRLR0) & (~(BIT_ADDR_CH(3)|BIT_DATA_CH(3)))) |
|
||||
(BIT_ADDR_CH(2)|BIT_DATA_CH(2))));
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
// Enable SPI_FLASH User Mode
|
||||
// HAL_SPI_WRITE32(REG_SPIC_SSIENR, BIT_SPIC_EN);
|
||||
}
|
||||
|
||||
|
||||
#include "hal_timer.h"
|
||||
extern BOOL
|
||||
HalTimerInitRtl8195a(
|
||||
IN void *Data
|
||||
);
|
||||
|
||||
void
|
||||
PatchHalInitPlatformTimer(
|
||||
void
|
||||
)
|
||||
{
|
||||
TIMER_ADAPTER TimerAdapter;
|
||||
|
||||
OSC32K_CKGEN_CTRL(ON);
|
||||
GTIMER_FCTRL(ON);
|
||||
ACTCK_TIMER_CCTRL(ON);
|
||||
SLPCK_TIMER_CCTRL(ON);
|
||||
|
||||
TimerAdapter.IrqDis = ON;
|
||||
// TimerAdapter.IrqHandle = (IRQ_FUN)NULL;
|
||||
TimerAdapter.TimerId = 1;
|
||||
TimerAdapter.TimerIrqPriority = 0;
|
||||
TimerAdapter.TimerLoadValueUs = 0;
|
||||
TimerAdapter.TimerMode = FREE_RUN_MODE;
|
||||
|
||||
HalTimerInitRtl8195a((void*) &TimerAdapter);
|
||||
|
||||
}
|
||||
|
||||
#define UART_BAUD_RATE_2400 2400
|
||||
#define UART_BAUD_RATE_4800 4800
|
||||
#define UART_BAUD_RATE_9600 9600
|
||||
#define UART_BAUD_RATE_19200 19200
|
||||
#define UART_BAUD_RATE_38400 38400
|
||||
#define UART_BAUD_RATE_57600 57600
|
||||
#define UART_BAUD_RATE_115200 115200
|
||||
#define UART_BAUD_RATE_921600 921600
|
||||
#define UART_BAUD_RATE_1152000 1152000
|
||||
|
||||
#define UART_PARITY_ENABLE 0x08
|
||||
#define UART_PARITY_DISABLE 0
|
||||
|
||||
#define UART_DATA_LEN_5BIT 0x0
|
||||
#define UART_DATA_LEN_6BIT 0x1
|
||||
#define UART_DATA_LEN_7BIT 0x2
|
||||
#define UART_DATA_LEN_8BIT 0x3
|
||||
|
||||
#define UART_STOP_1BIT 0x0
|
||||
#define UART_STOP_2BIT 0x4
|
||||
|
||||
|
||||
extern uint32_t
|
||||
HalLogUartInit(
|
||||
IN LOG_UART_ADAPTER UartAdapter
|
||||
);
|
||||
|
||||
extern uint32_t
|
||||
HalGetCpuClk(
|
||||
void
|
||||
);
|
||||
|
||||
const uint32_t StartupCpkClkTbl[]= {
|
||||
200000000,
|
||||
100000000,
|
||||
50000000,
|
||||
25000000,
|
||||
12500000,
|
||||
4000000
|
||||
};
|
||||
|
||||
|
||||
uint32_t
|
||||
StartupHalGetCpuClk(
|
||||
void
|
||||
)
|
||||
{
|
||||
uint32_t CpuType = 0, CpuClk = 0, FreqDown = 0;
|
||||
|
||||
CpuType = ((HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_CLK_CTRL1) & (0x70)) >> 4);
|
||||
FreqDown = HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_SYSPLL_CTRL1) & BIT17;
|
||||
|
||||
CpuClk = StartupCpkClkTbl[CpuType];
|
||||
|
||||
if ( !FreqDown ) {
|
||||
if ( CpuClk > 4000000 ){
|
||||
CpuClk = (CpuClk*5/6);
|
||||
}
|
||||
}
|
||||
|
||||
return CpuClk;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
PatchHalLogUartInit(
|
||||
IN LOG_UART_ADAPTER UartAdapter
|
||||
)
|
||||
{
|
||||
uint32_t SetData;
|
||||
uint32_t Divisor;
|
||||
uint32_t Dlh;
|
||||
uint32_t Dll;
|
||||
uint32_t SysClock;
|
||||
|
||||
/*
|
||||
Interrupt enable Register
|
||||
7: THRE Interrupt Mode Enable
|
||||
2: Enable Receiver Line Status Interrupt
|
||||
1: Enable Transmit Holding Register Empty Interrupt
|
||||
0: Enable Received Data Available Interrupt
|
||||
*/
|
||||
// disable all interrupts
|
||||
HAL_UART_WRITE32(UART_INTERRUPT_EN_REG_OFF, 0);
|
||||
|
||||
/*
|
||||
Line Control Register
|
||||
7: DLAB, enable reading and writing DLL and DLH register, and must be cleared after
|
||||
initial baud rate setup
|
||||
3: PEN, parity enable/disable
|
||||
2: STOP, stop bit
|
||||
1:0 DLS, data length
|
||||
*/
|
||||
|
||||
// set DLAB bit to 1
|
||||
HAL_UART_WRITE32(UART_LINE_CTL_REG_OFF, 0x80);
|
||||
|
||||
// set up buad rate division
|
||||
|
||||
#ifdef CONFIG_FPGA
|
||||
SysClock = SYSTEM_CLK;
|
||||
Divisor = (SysClock / (16 * (UartAdapter.BaudRate)));
|
||||
#else
|
||||
{
|
||||
uint32_t SampleRate,Remaind;
|
||||
|
||||
//SysClock = (HalGetCpuClk()>>2);
|
||||
SysClock = (StartupHalGetCpuClk()>>2);
|
||||
|
||||
SampleRate = (16 * (UartAdapter.BaudRate));
|
||||
|
||||
Divisor= SysClock/SampleRate;
|
||||
|
||||
Remaind = ((SysClock*10)/SampleRate) - (Divisor*10);
|
||||
|
||||
if (Remaind>4) {
|
||||
Divisor++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Dll = Divisor & 0xff;
|
||||
Dlh = (Divisor & 0xff00)>>8;
|
||||
HAL_UART_WRITE32(UART_DLL_OFF, Dll);
|
||||
HAL_UART_WRITE32(UART_DLH_OFF, Dlh);
|
||||
|
||||
// clear DLAB bit
|
||||
HAL_UART_WRITE32(UART_LINE_CTL_REG_OFF, 0);
|
||||
|
||||
// set data format
|
||||
SetData = UartAdapter.Parity | UartAdapter.Stop | UartAdapter.DataLength;
|
||||
HAL_UART_WRITE32(UART_LINE_CTL_REG_OFF, SetData);
|
||||
|
||||
/* FIFO Control Register
|
||||
7:6 level of receive data available interrupt
|
||||
5:4 level of TX empty trigger
|
||||
2 XMIT FIFO reset
|
||||
1 RCVR FIFO reset
|
||||
0 FIFO enable/disable
|
||||
*/
|
||||
// FIFO setting, enable FIFO and set trigger level (2 less than full when receive
|
||||
// and empty when transfer
|
||||
HAL_UART_WRITE32(UART_FIFO_CTL_REG_OFF, UartAdapter.FIFOControl);
|
||||
|
||||
/*
|
||||
Interrupt Enable Register
|
||||
7: THRE Interrupt Mode enable
|
||||
2: Enable Receiver Line status Interrupt
|
||||
1: Enable Transmit Holding register empty INT32
|
||||
0: Enable received data available interrupt
|
||||
*/
|
||||
HAL_UART_WRITE32(UART_INTERRUPT_EN_REG_OFF, UartAdapter.IntEnReg);
|
||||
|
||||
if (UartAdapter.IntEnReg) {
|
||||
// Enable Peripheral_IRQ Setting for Log_Uart
|
||||
HAL_WRITE32(VENDOR_REG_BASE, PERIPHERAL_IRQ_EN, 0x1000000);
|
||||
|
||||
// Enable ARM Cortex-M3 IRQ
|
||||
NVIC_SetPriorityGrouping(0x3);
|
||||
NVIC_SetPriority(PERIPHERAL_IRQ, 14);
|
||||
NVIC_EnableIRQ(PERIPHERAL_IRQ);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t log_uart_irq(void *Data)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
PatchHalInitPlatformLogUart(
|
||||
void
|
||||
)
|
||||
{
|
||||
IRQ_HANDLE UartIrqHandle;
|
||||
LOG_UART_ADAPTER UartAdapter;
|
||||
|
||||
//4 Release log uart reset and clock
|
||||
LOC_UART_FCTRL(OFF);
|
||||
LOC_UART_FCTRL(ON);
|
||||
ACTCK_LOG_UART_CCTRL(ON);
|
||||
|
||||
PinCtrl(LOG_UART,S0,ON);
|
||||
|
||||
//4 Register Log Uart Callback function
|
||||
UartIrqHandle.Data = (uint32_t)NULL;//(uint32_t)&UartAdapter;
|
||||
UartIrqHandle.IrqNum = UART_LOG_IRQ;
|
||||
UartIrqHandle.IrqFun = (IRQ_FUN) log_uart_irq;//UartLogIrqHandleRam;
|
||||
UartIrqHandle.Priority = 0;
|
||||
|
||||
//4 Inital Log uart
|
||||
UartAdapter.BaudRate = DEFAULT_BAUDRATE;
|
||||
UartAdapter.DataLength = UART_DATA_LEN_8BIT;
|
||||
UartAdapter.FIFOControl = 0xC1;
|
||||
UartAdapter.IntEnReg = 0x00;
|
||||
UartAdapter.Parity = UART_PARITY_DISABLE;
|
||||
UartAdapter.Stop = UART_STOP_1BIT;
|
||||
|
||||
//4 Initial Log Uart
|
||||
PatchHalLogUartInit(UartAdapter);
|
||||
|
||||
//4 Register Isr handle
|
||||
InterruptRegister(&UartIrqHandle);
|
||||
|
||||
UartAdapter.IntEnReg = 0x05;
|
||||
|
||||
//4 Initial Log Uart for Interrupt
|
||||
PatchHalLogUartInit(UartAdapter);
|
||||
|
||||
//4 initial uart log parameters before any uartlog operation
|
||||
//RtlConsolInit(ROM_STAGE,GetRomCmdNum(),(void*)&UartLogRomCmdTable);// executing boot seq.,
|
||||
}
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
decompiled low_level_io.o
|
||||
*/
|
||||
#include ......
|
||||
//-------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
void mode_init();
|
||||
void HalSerialPutcRtl8195a(int c, int a2, char a3);
|
||||
signed int DiagPrintf(const char *fmt, ...);
|
||||
void log_uart_enable_printf();
|
||||
void log_uart_disable_printf();
|
||||
//-------------------------------------------------------------------------
|
||||
// Data declarations
|
||||
uint32_t backupWarn;
|
||||
uint32_t backupErr;
|
||||
uint32_t backupInfo;
|
||||
int disablePrintf;
|
||||
// extern _UNKNOWN use_mode;
|
||||
// extern _UNKNOWN ConfigDebugErr;
|
||||
// extern _UNKNOWN ConfigDebugInfo;
|
||||
// extern _UNKNOWN ConfigDebugWarn;
|
||||
|
||||
//-----
|
||||
void mode_init()
|
||||
{
|
||||
use_mode = 1;
|
||||
}
|
||||
|
||||
//-----
|
||||
void HalSerialPutcRtl8195a(int c)
|
||||
{
|
||||
signed int v3; // r3@2
|
||||
|
||||
if ( disablePrintf != 1 )
|
||||
{
|
||||
v3 = 6540;
|
||||
do
|
||||
{
|
||||
if ( !--v3 )
|
||||
break;
|
||||
a3 = v40003014;
|
||||
}
|
||||
while ( !(v40003014 & 0x60) );
|
||||
if ( c == 10 ) a3 = 13;
|
||||
v40003000 = c;
|
||||
if ( c == 10 ) v40003000 = a3;
|
||||
}
|
||||
}
|
||||
|
||||
//-----
|
||||
signed int DiagPrintf(const char *fmt, ...)
|
||||
{
|
||||
va_list va;
|
||||
|
||||
va_start(va, fmt);
|
||||
if ( disablePrintf != 1 )
|
||||
VSprintf(0, fmt, va);
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-----
|
||||
void log_uart_enable_printf()
|
||||
{
|
||||
disablePrintf = 0;
|
||||
ConfigDebugErr = backupErr;
|
||||
ConfigDebugInfo = backupInfo;
|
||||
ConfigDebugWarn = backupWarn;
|
||||
}
|
||||
|
||||
//-----
|
||||
void log_uart_disable_printf()
|
||||
{
|
||||
disablePrintf = 1;
|
||||
backupErr = ConfigDebugErr;
|
||||
backupInfo = ConfigDebugInfo;
|
||||
backupWarn = ConfigDebugWarn;
|
||||
ConfigDebugErr = 0;
|
||||
ConfigDebugInfo = 0;
|
||||
ConfigDebugWarn = 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,175 @@
|
|||
/*
|
||||
* rtl_bios_data.c
|
||||
*
|
||||
* Created on: 12/02/2017
|
||||
* Author: pvvx
|
||||
*
|
||||
* This variables declared in ROM code!
|
||||
* Variables use fixed addresses!
|
||||
* (see *.ld script)
|
||||
*/
|
||||
|
||||
#include "rtl_bios_data.h"
|
||||
extern void * UartLogRomCmdTable;
|
||||
/* ROM + startup.c */
|
||||
RAM_DEDECATED_VECTOR_TABLE_SECTION IRQ_FUN NewVectorTable[64]; // 10000000
|
||||
RAM_USER_IRQ_FUN_TABLE_SECTION IRQ_FUN UserIrqFunTable[64]; // 10000100
|
||||
RAM_USER_IRQ_DATA_TABLE_SECTION uint32_t UserIrqDataTable[64]; // 10000200
|
||||
/* ROM + ... */
|
||||
HAL_RAM_BSS_SECTION PHAL_GPIO_ADAPTER _pHAL_Gpio_Adapter; // 10000354
|
||||
/* ROM + hal_ssi.h */
|
||||
HAL_RAM_BSS_SECTION uint32_t SSI_DBG_CONFIG; // 10000350
|
||||
/* ROM + hal_timer.h & .. */
|
||||
HAL_RAM_BSS_SECTION uint32_t gTimerRecord; // 1000034C
|
||||
HAL_RAM_BSS_SECTION uint16_t GPIOState[11]; // 10000334
|
||||
HAL_RAM_BSS_SECTION HAL_TIMER_OP HalTimerOp; // 10000318
|
||||
/* ROM + diag.h */
|
||||
HAL_RAM_BSS_SECTION uint32_t ConfigDebugErr; // 10000314
|
||||
HAL_RAM_BSS_SECTION uint32_t ConfigDebugInfo; // 10000310
|
||||
HAL_RAM_BSS_SECTION uint32_t ConfigDebugWarn; // 1000030C
|
||||
HAL_RAM_BSS_SECTION uint32_t CfgSysDebugErr; // 10000308
|
||||
HAL_RAM_BSS_SECTION uint32_t CfgSysDebugInfo; // 10000304
|
||||
HAL_RAM_BSS_SECTION uint32_t CfgSysDebugWarn; // 10000300
|
||||
/* ROM + rtl8195a_timer.c */
|
||||
SECTION_RAM_TIMER2TO7_VECTOR_TABLE IRQ_FUN Timer2To7VectorTable[MAX_TIMER_VECTOR_TABLE_NUM]; // 10000358 Timer2To7VectorTable[6] !
|
||||
/* ROM + Rand() */
|
||||
INFRA_RAM_BSS_SECTION uint32_t _rand_z4, _rand_z3, _rand_z2, _rand_z1, _rand_first; // 10000370..
|
||||
/* ROM + RTL_CONSOL */
|
||||
MON_RAM_BSS_SECTION uint8_t *ArgvArray[MAX_ARGV]; // 100006AC *ArgvArray[10] !
|
||||
MON_RAM_BSS_SECTION uint8_t UartLogHistoryBuf[UART_LOG_HISTORY_LEN][UART_LOG_CMD_BUFLEN]; // 10000430 UartLogHistoryBuf[5][127] !
|
||||
MON_RAM_BSS_SECTION volatile UART_LOG_CTL UartLogCtl; // 10000408
|
||||
/* = {
|
||||
.NewIdx = 0,
|
||||
.SeeIdx = 0,
|
||||
.RevdNo = UART_LOG_HISTORY_LEN,
|
||||
.EscSTS = 0,
|
||||
.ExecuteCmd = 0,
|
||||
.ExecuteEsc = 0,
|
||||
.BootRdy = 0,
|
||||
.Resvd = 0,
|
||||
.pTmpLogBuf = &UartLogBuf,
|
||||
.pfINPUT = (void*) &DiagPrintf,
|
||||
.pCmdTbl = (PCOMMAND_TABLE) &UartLogRomCmdTable,
|
||||
.CmdTblSz = 6,
|
||||
.CRSTS = 0,
|
||||
.pHistoryBuf = &UartLogHistoryBuf,
|
||||
.TaskRdy = 0
|
||||
// .Sema
|
||||
}; */
|
||||
MON_RAM_BSS_SECTION UART_LOG_BUF UartLogBuf; // 10000388
|
||||
MON_RAM_BSS_SECTION volatile UART_LOG_CTL *pUartLogCtl = &UartLogCtl; // 10000384
|
||||
/* ROM + LIB C */
|
||||
LIBC_RAM_BSS_SECTION int __rtl_errno; // 10000bc4 __rtl_sread_v1_00(), __rtl_write_v1_00(), __rtl_lseek_v1_00(), __rtl_close_v1_00(), __rtl_sbrk_v1_00()..
|
||||
LIBC_RAM_BSS_SECTION struct mallinfo __rtl_malloc_current_mallinfo; // 10000b9c __rom_mallocr_init_v1_00()
|
||||
LIBC_RAM_BSS_SECTION uint32_t __rtl_malloc_max_total_mem; // 10000b98 __rom_mallocr_init_v1_00()
|
||||
LIBC_RAM_BSS_SECTION uint32_t __rtl_malloc_max_sbrked_mem; // 10000b94 __rom_mallocr_init_v1_00()
|
||||
LIBC_RAM_BSS_SECTION uint8_t * __rtl_malloc_sbrk_base; // 10000b90 __rom_mallocr_init_v1_00()
|
||||
LIBC_RAM_BSS_SECTION uint32_t __rtl_malloc_top_pad; // 10000b8c __rom_mallocr_init_v1_00()
|
||||
LIBC_RAM_BSS_SECTION uint32_t __rtl_malloc_trim_threshold; // 10000b88 __rom_mallocr_init_v1_00()
|
||||
LIBC_RAM_BSS_SECTION struct malloc_chunk *__rtl_malloc_av_[258]; // 0x10000780 __rom_mallocr_init_v1_00(), _rtl_free_r_v1_00()..
|
||||
LIBC_RAM_BSS_SECTION __attribute__((aligned(0x10))) struct _rom_libgloss_ram_map rom_libgloss_ram_map; // 10000760
|
||||
|
||||
// 10000BA0..10000BC0: 9 x dw __rom_mallocr_init_v1_00()
|
||||
|
||||
/* ROM: ROM_odm_FalseAlarmCounterStatistics() + .. */
|
||||
#define _WLAN_RAM_MAP_SECTION __attribute__((__section__(".ram.rom.wlanmap")))
|
||||
_WLAN_RAM_MAP_SECTION CFO_TRACKING DM_CfoTrack; // 10000738
|
||||
_WLAN_RAM_MAP_SECTION ROM_INFO ROMInfo; // 10000720
|
||||
_WLAN_RAM_MAP_SECTION __attribute__((aligned(0x10))) FALSE_ALARM_STATISTICS FalseAlmCnt; // 100006E0
|
||||
WLAN_RAM_MAP_SECTION struct _rom_wlan_ram_map rom_wlan_ram_map; // 100006D4
|
||||
|
||||
#ifndef PRESENT_IMAGE1
|
||||
/* IMAGE1 HEAD */
|
||||
START_RAM_FUN_SECTION RAM_FUNCTION_START_TABLE __ram_start_table_start__;
|
||||
/*
|
||||
START_RAM_FUN_A_SECTION RAM_START_FUNCTION gRamStartFun; // 10000bc8 = { PreProcessForVendor + 1 };
|
||||
START_RAM_FUN_B_SECTION RAM_START_FUNCTION gRamPatchWAKE; // 10000bcc = { RtlBootToSram + 1 };
|
||||
START_RAM_FUN_C_SECTION RAM_START_FUNCTION gRamPatchFun0; // 10000bd0 = { RtlBootToSram + 1 };
|
||||
START_RAM_FUN_D_SECTION RAM_START_FUNCTION gRamPatchFun1; // 10000bd4 = { RtlBootToSram + 1 };
|
||||
START_RAM_FUN_E_SECTION RAM_START_FUNCTION gRamPatchFun2; // 10000bd8 = { RtlBootToSram + 1 };
|
||||
*/
|
||||
#endif
|
||||
|
||||
IMAGE1_VALID_PATTEN_SECTION uint8 RAM_IMG1_VALID_PATTEN[8] = IMG1_VALID_PATTEN_INIT(); // 10000bdc
|
||||
|
||||
//#ifdef NOT_USE_LIBROM_A
|
||||
|
||||
/* ROM + hal_sdr_controller.c */
|
||||
//HAL_FLASH_DATA_SECTION
|
||||
//SPIC_INIT_PARA SpicInitParaAllClk[SpicMaxMode][CPU_CLK_TYPE_NO]; // SpicInitParaAllClk[3][6] !
|
||||
|
||||
/* ROM + hal_sdr_controller.c */
|
||||
HAL_CUT_B_RAM_DATA_SECTION DRAM_INFO SdrDramDev = DRAM_INFO_INIT(); // 10001c4c
|
||||
HAL_CUT_B_RAM_DATA_SECTION DRAM_MODE_REG_INFO SdrDramModeReg = DRAM_MODE_REG_INFO_INIT(); // 10001c30
|
||||
HAL_CUT_B_RAM_DATA_SECTION DRAM_TIMING_INFO SdrDramTiming = DRAM_TIMING_INFO_INIT(); // 10001bfc
|
||||
HAL_CUT_B_RAM_DATA_SECTION DRAM_DEVICE_INFO SdrDramInfo = DRAM_DEVICE_INFO_INIT(); // 10001be8
|
||||
HAL_CUT_B_RAM_DATA_SECTION uint32_t AvaWds[2][REC_NUM]; // 10000be8
|
||||
|
||||
/* ROM + hal_sdr_controller.c: Sdr_Rand2() */
|
||||
HAL_CUT_B_RAM_DATA_SECTION uint32_t rand_x = 123456789; // 10000be4
|
||||
|
||||
#define RTL_REENT_INIT(var) \
|
||||
{ 0, \
|
||||
&(var).__sf[0], \
|
||||
&(var).__sf[1], \
|
||||
&(var).__sf[2], \
|
||||
0, \
|
||||
"", \
|
||||
0, \
|
||||
(void *)0x0437DC, \
|
||||
0, \
|
||||
_NULL, \
|
||||
_NULL, \
|
||||
0, \
|
||||
_NULL, \
|
||||
_NULL, \
|
||||
0, \
|
||||
_NULL, \
|
||||
{ \
|
||||
{ \
|
||||
0, \
|
||||
_NULL, \
|
||||
"", \
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0}, \
|
||||
0, \
|
||||
1, \
|
||||
{ \
|
||||
{_RAND48_SEED_0, _RAND48_SEED_1, _RAND48_SEED_2}, \
|
||||
{_RAND48_MULT_0, _RAND48_MULT_1, _RAND48_MULT_2}, \
|
||||
_RAND48_ADD \
|
||||
}, \
|
||||
{0, {0}}, \
|
||||
{0, {0}}, \
|
||||
{0, {0}}, \
|
||||
"", \
|
||||
"", \
|
||||
0, \
|
||||
{0, {0}}, \
|
||||
{0, {0}}, \
|
||||
{0, {0}}, \
|
||||
{0, {0}}, \
|
||||
{0, {0}} \
|
||||
} \
|
||||
}, \
|
||||
_REENT_INIT_ATEXIT \
|
||||
_NULL, \
|
||||
{_NULL, 0, _NULL} \
|
||||
}
|
||||
// ROM: _rtl_impure_ptr + impure_reent in lib_rom.a ".hal.ram.data"
|
||||
__attribute__((section(".libc.reent"))) struct _reent impure_reent = RTL_REENT_INIT(impure_reent); // 10001c60
|
||||
__attribute__((section(".libc.reent"))) struct _reent * _rtl_impure_ptr = { &impure_reent }; // 10001c68
|
||||
|
||||
/* ROM ? */
|
||||
__attribute__((__section__(".rom.unc.data"))) uint32_t _rom_unc_data[9]; // 100020e8
|
||||
|
||||
/* ROM + hal_sdr_controller.c: Sdr_Rand2() */
|
||||
__attribute__((__section__(".sdr.rand2.data"))) uint32_t _sdr_rnd2_c = 7654321, _sdr_rnd2_z = 521288629, _sdr_rnd2_y = 362436;
|
||||
// 100020BC, 100020B8, 100020B4
|
||||
|
||||
HAL_GPIO_ADAPTER PINMUX_RAM_DATA_SECTION gBoot_Gpio_Adapter; // 100020C0 [300=0x12c]
|
||||
//SPIC_INIT_PARA HAL_FLASH_DATA_SECTION SpicInitParaAllClk[SpicMaxMode][CPU_CLK_TYPE_NO]; // 100021ec [144=0x90]
|
||||
|
||||
#ifndef PRESENT_IMAGE2
|
||||
IMAGE2_START_RAM_FUN_SECTION RAM_START_FUNCTION gImage2EntryFun0; //= { InfraStart + 1 };
|
||||
#endif
|
||||
IMAGE2_VALID_PATTEN_SECTION _RAM_IMG2_VALID_PATTEN RAM_IMG2_VALID_PATTEN = RAM_IMG2_VALID_PATTEN_INIT();
|
||||
|
|
@ -0,0 +1,769 @@
|
|||
/*
|
||||
* BootLoader Ver 0.3 (19/10/2017)
|
||||
* Created on: 12/02/2017
|
||||
* Author: pvvx
|
||||
*/
|
||||
|
||||
#include "platform_autoconf.h"
|
||||
#include "rtl_bios_data.h"
|
||||
#include "diag.h"
|
||||
#include "rtl8195a/rtl8195a_sys_on.h"
|
||||
#include "rtl8195a/rtl8195a_sdr.h"
|
||||
|
||||
#include "hal_spi_flash.h"
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Data declarations
|
||||
#ifndef DEFAULT_BAUDRATE
|
||||
#define DEFAULT_BAUDRATE 38400
|
||||
#endif
|
||||
|
||||
/* 0 - 166666666 Hz, 1 - 83333333 Hz, 2 - 41666666 Hz, 3 - 20833333 Hz, 4 - 10416666 Hz, 5 - 4000000? Hz,
|
||||
6 - 200000000 Hz, 7 - 10000000 Hz, 8 - 50000000 Hz, 9 - 25000000 Hz, 10 - 12500000 Hz, 11 - 4000000? Hz */
|
||||
#define DEFAULT_BOOT_CLK_CPU 1 // Warning! If Start CLK > 100 MHz -> Errors SPIC function in Ameba SDK!
|
||||
|
||||
#ifdef DEFAULT_BOOT_CLK_CPU
|
||||
#if DEFAULT_BOOT_CLK_CPU < 6
|
||||
#define DEFAULT_BOOT_CPU_CLOCK_SEL_DIV5_3 0
|
||||
#define DEFAULT_BOOT_CPU_CLOCK_SEL_VALUE DEFAULT_BOOT_CLK_CPU
|
||||
#else
|
||||
#define DEFAULT_BOOT_CPU_CLOCK_SEL_DIV5_3 1
|
||||
#define DEFAULT_BOOT_CPU_CLOCK_SEL_VALUE (DEFAULT_BOOT_CLK_CPU-6)
|
||||
#endif
|
||||
#endif // DEFAULT_BOOT_CLK_CPU
|
||||
#define FIX_SDR_CALIBRATION // for speed and low used SRAM
|
||||
#define BOOT_RAM_TEXT_SECTION // __attribute__((section(".boot.text")))
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
typedef struct _seg_header {
|
||||
uint32 size;
|
||||
uint32 ldaddr;
|
||||
uint32 sign[2];
|
||||
} IMGSEGHEAD, *PIMGSEGHEAD;
|
||||
|
||||
typedef struct _img2_header {
|
||||
IMGSEGHEAD seg;
|
||||
void (*startfunc)(void);
|
||||
uint8 rtkwin[7];
|
||||
uint8 ver[13];
|
||||
uint8 name[32];
|
||||
} IMG2HEAD, *PIMG2HEAD;
|
||||
|
||||
#ifndef FLASH_SECTOR_SIZE
|
||||
#define FLASH_SECTOR_SIZE 4096
|
||||
#endif
|
||||
//-------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
static void RtlBootToFlash(void); // image1
|
||||
static void RtlBoot1ToSram(void); // image1
|
||||
static void RtlBoot2ToSram(void); // image1
|
||||
static void RtlBoot3ToSram(void); // image1
|
||||
static void RtlBoot4ToSram(void); // image1
|
||||
|
||||
extern _LONG_CALL_ void HalCpuClkConfig(unsigned char CpuType);
|
||||
extern _LONG_CALL_ void VectorTableInitRtl8195A(uint32_t StackP);
|
||||
extern _LONG_CALL_ void HalInitPlatformLogUartV02(void);
|
||||
extern _LONG_CALL_ void HalInitPlatformTimerV02(void);
|
||||
//extern _LONG_CALL_ void DramInit_rom(IN DRAM_DEVICE_INFO *DramInfo);
|
||||
//extern _LONG_CALL_ uint32_t SdrCalibration_rom(void);
|
||||
extern _LONG_CALL_ uint32_t SpicCmpDataForCalibrationRtl8195A(void); // compare read_data and golden_data
|
||||
//extern _LONG_CALL_ void SpicWaitWipDoneRtl8195A(SPIC_INIT_PARA SpicInitPara); // wait spi-flash status register[0] = 0
|
||||
//extern _LONG_CALL_ void SpicLoadInitParaFromClockRtl8195A(uint8_t CpuClkMode, uint8_t BaudRate, PSPIC_INIT_PARA pSpicInitPara);
|
||||
//extern _LONG_CALL_ void RtlConsolInit(IN uint32_t Boot, IN uint32_t TBLSz, IN void *pTBL);
|
||||
|
||||
//#pragma arm section code = ".boot.text";
|
||||
//#pragma arm section rodata = ".boot.rodata", rwdata = ".boot.data", zidata = ".boot.bss";
|
||||
|
||||
typedef void (*START_FUNC)(void);
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
/* Start table: */
|
||||
START_RAM_FUN_SECTION RAM_FUNCTION_START_TABLE __ram_start_table_start__ = {
|
||||
RtlBootToFlash + 1, // StartFun(), Run if ( v400001F4 & 0x8000000 ) && ( v40000210 & 0x80000000 )
|
||||
RtlBoot1ToSram + 1, // PatchWAKE(), Run if ( v40000210 & 0x20000000 )
|
||||
RtlBoot2ToSram + 1, // PatchFun0(), Run if ( v40000210 & 0x10000000 )
|
||||
RtlBoot3ToSram + 1, // PatchFun1(), Run if ( v400001F4 & 0x8000000 ) && ( v40000210 & 0x8000000 )
|
||||
RtlBoot4ToSram + 1 };// PatchFun2(), Run for Init console, if ( v40000210 & 0x4000000 )
|
||||
//-------------------------------------------------------------------------
|
||||
/* Set Debug Flags */
|
||||
static void BOOT_RAM_TEXT_SECTION SetDebugFlgs() {
|
||||
#if CONFIG_DEBUG_LOG > 3
|
||||
CfgSysDebugWarn = -1;
|
||||
CfgSysDebugInfo = -1;
|
||||
CfgSysDebugErr = -1;
|
||||
ConfigDebugWarn = -1;
|
||||
ConfigDebugInfo = -1;
|
||||
ConfigDebugErr = -1;
|
||||
#elif CONFIG_DEBUG_LOG > 1
|
||||
CfgSysDebugWarn = -1;
|
||||
// CfgSysDebugInfo = 0;
|
||||
CfgSysDebugErr = -1;
|
||||
ConfigDebugWarn = -1;
|
||||
// ConfigDebugInfo = 0;
|
||||
ConfigDebugErr = -1; //~_DBG_SDR_;
|
||||
#elif CONFIG_DEBUG_LOG > 0
|
||||
// CfgSysDebugWarn = 0;
|
||||
// CfgSysDebugInfo = 0;
|
||||
CfgSysDebugErr = -1;
|
||||
// ConfigDebugWarn = 0;
|
||||
// ConfigDebugInfo = 0;
|
||||
ConfigDebugErr = -1; //~_DBG_SDR_;
|
||||
#else
|
||||
// CfgSysDebugWarn = 0;
|
||||
// CfgSysDebugInfo = 0;
|
||||
// CfgSysDebugErr = 0;
|
||||
// ConfigDebugWarn = 0;
|
||||
// ConfigDebugInfo = 0;
|
||||
// ConfigDebugErr = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* JTAG On */
|
||||
static void BOOT_RAM_TEXT_SECTION JtagOn(void) {
|
||||
ACTCK_VENDOR_CCTRL(ON);
|
||||
SLPCK_VENDOR_CCTRL(ON);
|
||||
HalPinCtrlRtl8195A(JTAG, 0, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* 16 bytes FIFO ... 16*11/38400 = 0.004583 sec
|
||||
* (0.005/5)*166666666 = 166666.666 Tcpu
|
||||
*/
|
||||
static void INFRA_START_SECTION loguart_wait_tx_fifo_empty(void) {
|
||||
if (HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) & BIT_SOC_LOG_UART_EN) {
|
||||
int x = 16384;
|
||||
while ((!(HAL_READ8(LOG_UART_REG_BASE, 0x14) & BIT6)) && x--)
|
||||
; // иначе глючит LogUART, если переключение CLK приходится на вывод символов !
|
||||
}
|
||||
}
|
||||
|
||||
extern SPIC_INIT_PARA SpicInitParaAllClk[SpicMaxMode][CPU_CLK_TYPE_NO]; // 100021ec [144=0x90]
|
||||
static uint32 InitTabParaAllClk[3 * CPU_CLK_TYPE_NO] = {
|
||||
// SIO
|
||||
0x01310102, // 72t/byte
|
||||
0x03310101, // 0201 - 40t, 0101 - 39t, 0102 - 72t, 0103 - 104t
|
||||
0x05310001, // 39t
|
||||
0x07310001,
|
||||
0x09310001,
|
||||
0x0B310001,
|
||||
// DIO
|
||||
0x11311301, // BaudRate = 1, RdDummyCyle = 19, DelayLine = 63, DIO
|
||||
0x13311201, // 1201 - 36t
|
||||
0x15311101, // 1101 - 35t
|
||||
0x17311101,
|
||||
0x19311101,
|
||||
0x1B311101
|
||||
// QIO
|
||||
/* MXIC Flash only DIO!
|
||||
0x21311301, // BaudRate = 1, RdDummyCyle = 19, DelayLine = 63, DIO
|
||||
0x23311201, // 1201 - 36t
|
||||
0x25311101, // 1101 - 35t
|
||||
0x27311101,
|
||||
0x29311101,
|
||||
0x2B311101
|
||||
*/
|
||||
};
|
||||
|
||||
struct spic_table_flash_type {
|
||||
uint8 cmd[12];
|
||||
uint8 strlr2;
|
||||
uint8 fbaud;
|
||||
uint8 addrlen;
|
||||
uint8 fsize;
|
||||
uint32 contrl;
|
||||
uint16 validcmd[3];
|
||||
uint8 manufacturerid;
|
||||
uint8 memorytype;
|
||||
};
|
||||
|
||||
//PSPIC_INIT_PARA pSpicInitPara;
|
||||
|
||||
struct spic_table_flash_type spic_table_flash = {
|
||||
{ // for FLASH MX25L8006E/1606E
|
||||
FLASH_CMD_FREAD, // REG_SPIC_READ_FAST_SINGLE 0x400060E0 0x0B
|
||||
FLASH_CMD_DREAD, // REG_SPIC_READ_DUAL_DATA 0x400060E4 0x3B
|
||||
FLASH_CMD_DREAD, // REG_SPIC_READ_DUAL_ADDR_DATA 0x400060E8 0x3B ?
|
||||
FLASH_CMD_QREAD, // REG_SPIC_READ_QUAD_DATA 0x400060EC 0x6B
|
||||
FLASH_CMD_4READ, // REG_SPIC_READ_QUAD_ADDR_DATA 0x400060F0 0xEB ?
|
||||
FLASH_CMD_PP, // REG_SPIC_WRITE_SIGNLE 0x400060F4 0x02
|
||||
FLASH_CMD_DPP, // REG_SPIC_WRITE_DUAL_DATA 0x400060F8 0xA2
|
||||
FLASH_CMD_DPP, // REG_SPIC_WRITE_DUAL_ADDR_DATA 0x400060FC 0xA2 ?
|
||||
FLASH_CMD_QPP, // REG_SPIC_WRITE_QUAD_DATA 0x40006100 0x32
|
||||
FLASH_CMD_4PP, // REG_SPIC_WRITE_QUAD_ADDR_DATA 0x40006104 0x38
|
||||
FLASH_CMD_WREN, // REG_SPIC_WRITE_ENABLE 0x40006108 0x06
|
||||
FLASH_CMD_RDSR // REG_SPIC_READ_STATUS 0x4000610C 0x05
|
||||
},
|
||||
BIT_FIFO_ENTRY(5) | BIT_SO_DUM, // REG_SPIC_CTRLR2 0x40006110 0x51
|
||||
BIT_FSCKDV(1), // REG_SPIC_FBAUDR 0x40006114 0x01
|
||||
BIT_ADDR_PHASE_LENGTH(3), // REG_SPIC_ADDR_LENGTH 0x40006118 0x03
|
||||
BIT_FLASE_SIZE(0x0F), // REG_SPIC_FLASE_SIZE 0x40006124 0x0E ?
|
||||
BIT_CS_H_WR_DUM_LEN(2)| BIT_AUTO_ADDR__LENGTH(3) | BIT_RD_DUMMY_LENGTH(0x0), // REG_SPIC_AUTO_LENGTH 0x4000611C 0x20030001 ?
|
||||
{
|
||||
BIT_WR_BLOCKING, // REG_SPIC_VALID_CMD 0x40006120 0x200 SpicOneBitMode
|
||||
BIT_WR_BLOCKING | BIT_RD_DUAL_I, // REG_SPIC_VALID_CMD 0x40006120 0x202 SpicDualBitMode
|
||||
BIT_WR_BLOCKING | BIT_RD_DUAL_I, // REG_SPIC_VALID_CMD 0x40006120 0x202 SpicDualBitMode
|
||||
// BIT_WR_BLOCKING | BIT_RD_QUAD_O, // REG_SPIC_VALID_CMD 0x40006120 0x208 SpicQuadBitMode MXIC not QIO
|
||||
},
|
||||
0xC2, 0x20 // MX25L8006/MX25L1606
|
||||
};
|
||||
|
||||
static int BOOT_RAM_TEXT_SECTION SetSpicBitMode(uint8 BitMode) {
|
||||
PSPIC_INIT_PARA pspic = &SpicInitParaAllClk[BitMode][((HAL_SYS_CTRL_READ32(REG_SYS_CLK_CTRL1) >> 4) & 7)];
|
||||
if(pspic->Mode.Valid) {
|
||||
// Disable SPI_FLASH User Mode
|
||||
HAL_SPI_WRITE32(REG_SPIC_SSIENR, 0);
|
||||
HAL_SPI_WRITE32(REG_SPIC_VALID_CMD, spic_table_flash.validcmd[pspic->Mode.BitMode]);
|
||||
HAL_SPI_WRITE32(REG_SPIC_AUTO_LENGTH, (HAL_SPI_READ32(REG_SPIC_AUTO_LENGTH) & 0xFFFF0000) | pspic->RdDummyCyle);
|
||||
HAL_SPI_WRITE32(REG_SPIC_BAUDR, pspic->BaudRate);
|
||||
FLASH_DDL_FCTRL(pspic->DelayLine); // SPI_DLY_CTRL_ADDR [7:0]
|
||||
// Enable SPI_FLASH User Mode
|
||||
HAL_SPI_WRITE32(REG_SPIC_SSIENR, BIT_SPIC_EN);
|
||||
}
|
||||
SPI_FLASH_PIN_FCTRL(ON);
|
||||
// Test Read Pattern
|
||||
if(!SpicCmpDataForCalibrationRtl8195A()) {
|
||||
FLASH_DDL_FCTRL(0x31); // SPI_DLY_CTRL_ADDR [7:0]
|
||||
for(uint8 BaudRate = 1; BaudRate < 4; BaudRate++) {
|
||||
for(uint8 RdDummyCyle = 0; RdDummyCyle < 63; RdDummyCyle++) {
|
||||
// Disable SPI_FLASH User Mode
|
||||
HAL_SPI_WRITE32(REG_SPIC_SSIENR, 0);
|
||||
HAL_SPI_WRITE32(REG_SPIC_AUTO_LENGTH, (HAL_SPI_READ32(REG_SPIC_AUTO_LENGTH) & 0xFFFF0000) | RdDummyCyle);
|
||||
HAL_SPI_WRITE32(REG_SPIC_BAUDR, BaudRate);
|
||||
// Enable SPI_FLASH User Mode
|
||||
HAL_SPI_WRITE32(REG_SPIC_SSIENR, BIT_SPIC_EN);
|
||||
// HAL_SPI_WRITE32(REG_SPIC_FLUSH_FIFO, 1);
|
||||
if(SpicCmpDataForCalibrationRtl8195A()) {
|
||||
DiagPrintf("Spic reinit %d:%d\n", BaudRate, RdDummyCyle);
|
||||
pspic->BaudRate = BaudRate;
|
||||
pspic->RdDummyCyle = RdDummyCyle;
|
||||
pspic->DelayLine = 0x31;
|
||||
pspic->Mode.Valid = 1;
|
||||
return 1;
|
||||
};
|
||||
};
|
||||
};
|
||||
return 0;
|
||||
};
|
||||
return 1;
|
||||
}
|
||||
|
||||
void BOOT_RAM_TEXT_SECTION InitSpicFlashType(struct spic_table_flash_type *ptable_flash) {
|
||||
uint8_t * ptrb = (uint8_t *) &ptable_flash->cmd;
|
||||
volatile uint32_t * ptrreg = (volatile uint32_t *)(SPI_FLASH_CTRL_BASE + REG_SPIC_READ_FAST_SINGLE);// 0x400060E0
|
||||
HAL_SPI_WRITE32(REG_SPIC_SSIENR, 0); // Disable SPI_FLASH User Mode
|
||||
do {
|
||||
*ptrreg++ = *ptrb++;
|
||||
} while(ptrb < (uint8_t *)(&ptable_flash->fsize));
|
||||
ptrreg[0] = ptable_flash->contrl;
|
||||
ptrreg[1] = ptable_flash->validcmd[SpicOneBitMode];
|
||||
ptrreg[2] = ptable_flash->fsize;
|
||||
HAL_SPI_WRITE32(REG_SPIC_SER, BIT_SER);
|
||||
}
|
||||
|
||||
static int BOOT_RAM_TEXT_SECTION InitSpic(uint8 SpicBitMode) {
|
||||
_memset(SpicInitParaAllClk, 0, sizeof(SpicInitParaAllClk));
|
||||
uint32 * ptr = InitTabParaAllClk;
|
||||
uint8 x;
|
||||
for(x = 0; x < SpicMaxMode; x++) {
|
||||
*(uint32 *)&SpicInitParaAllClk[SpicOneBitMode][x].BaudRate = ptr[0];
|
||||
*(uint32 *)&SpicInitParaAllClk[SpicDualBitMode][x].BaudRate = ptr[CPU_CLK_TYPE_NO];
|
||||
*(uint32 *)&SpicInitParaAllClk[SpicQuadBitMode][x].BaudRate = ptr[CPU_CLK_TYPE_NO]; // MXIC not QIO
|
||||
ptr++;
|
||||
}
|
||||
ACTCK_FLASH_CCTRL(1);
|
||||
SLPCK_FLASH_CCTRL(1);
|
||||
HalPinCtrlRtl8195A(SPI_FLASH, 0, ON);
|
||||
InitSpicFlashType(&spic_table_flash);
|
||||
return SetSpicBitMode(SpicBitMode);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SDR_EN
|
||||
|
||||
/* GetChipId() */
|
||||
static uint8 INFRA_START_SECTION _Get_ChipId() {
|
||||
uint8 ChipId = CHIP_ID_8710AF;
|
||||
if (HALEFUSEOneByteReadROM(HAL_SYS_CTRL_READ32(REG_SYS_EFUSE_CTRL), 0xF8,
|
||||
&ChipId, L25EOUTVOLTAGE) != 1)
|
||||
DBG_8195A("Get Chip ID Failed\r");
|
||||
return ChipId;
|
||||
}
|
||||
|
||||
static void INFRA_START_SECTION sdr_preinit(void) {
|
||||
|
||||
HAL_SYS_CTRL_WRITE32(REG_SYS_REGU_CTRL0,
|
||||
((HAL_SYS_CTRL_READ32(REG_SYS_REGU_CTRL0) & 0xfffff) | BIT_SYS_REGU_LDO25M_ADJ(0x03))); // ROM: BIT_SYS_REGU_LDO25M_ADJ(0x0e)? HAL RAM BIT_SYS_REGU_LDO25M_ADJ(0x03)
|
||||
LDO25M_CTRL(ON);
|
||||
SRAM_MUX_CFG(0x2);
|
||||
SDR_CLK_SEL(SDR_CLOCK_SEL_VALUE); // REG_PESOC_CLK_SEL
|
||||
HalPinCtrlRtl8195A(SDR, 0, ON); // SDR_PIN_FCTRL(ON);
|
||||
ACTCK_SDR_CCTRL(ON);
|
||||
SLPCK_SDR_CCTRL(ON);
|
||||
HAL_PERI_ON_WRITE32(REG_GPIO_PULL_CTRL4, 0);
|
||||
MEM_CTRL_FCTRL(ON);
|
||||
// HalDelayUs(1000);
|
||||
}
|
||||
|
||||
#ifndef FIX_SDR_CALIBRATION
|
||||
extern _LONG_CALL_ int SdrCalibration_rom(void);
|
||||
extern _LONG_CALL_ unsigned int Rand(void);
|
||||
extern _LONG_CALL_ int SdrControllerInit_rom(PDRAM_DEVICE_INFO pDramInfo);
|
||||
|
||||
static int INFRA_START_SECTION sdr_test(u32 LoopCnt) {
|
||||
u32 LoopIndex = 0;
|
||||
u32 Value32, Addr;
|
||||
for (LoopIndex = 0; LoopIndex < LoopCnt; LoopIndex++) {
|
||||
Value32 = Rand();
|
||||
Addr = Rand();
|
||||
Addr &= 0x1FFFFF;
|
||||
Addr &= (~0x3);
|
||||
HAL_SDRAM_WRITE32(Addr, Value32);
|
||||
if (HAL_SDRAM_READ32(Addr) != Value32)
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int INFRA_START_SECTION sdr_init_from_flash(void) {
|
||||
#define RdPipe 0
|
||||
#if DEFAULT_BOOT_CLK_CPU < 6
|
||||
#define TapCnt 0x11
|
||||
#elif DEFAULT_BOOT_CLK_CPU == 7
|
||||
#define TapCnt 0x23
|
||||
#else
|
||||
#define TapCnt 0x19
|
||||
#endif
|
||||
// set all_mode _idle
|
||||
HAL_SDR_WRITE32(REG_SDR_CSR, 0x700);
|
||||
// WRAP_MISC setting
|
||||
HAL_SDR_WRITE32(REG_SDR_MISC, 0x00000001);
|
||||
// PCTL setting
|
||||
HAL_SDR_WRITE32(REG_SDR_DCR, 0x00000008);
|
||||
HAL_SDR_WRITE32(REG_SDR_IOCR, RdPipe << PCTL_IOCR_RD_PIPE_BFO);
|
||||
HAL_SDR_WRITE32(REG_SDR_EMR2, 0x00000000);
|
||||
HAL_SDR_WRITE32(REG_SDR_EMR1, 0x00000006);
|
||||
HAL_SDR_WRITE32(REG_SDR_MR, 0x00000022);
|
||||
HAL_SDR_WRITE32(REG_SDR_DRR, 0x09030e07);
|
||||
HAL_SDR_WRITE32(REG_SDR_TPR0, 0x00002652);
|
||||
HAL_SDR_WRITE32(REG_SDR_TPR1, 0x00068873);
|
||||
HAL_SDR_WRITE32(REG_SDR_TPR2, 0x00000042);
|
||||
// start to init
|
||||
HAL_SDR_WRITE32(REG_SDR_CCR, 0x01);
|
||||
DBG_8195A("SDR calibration: %02x-%02x\n", RdPipe, TapCnt);
|
||||
while ((HAL_SDR_READ32(REG_SDR_CCR) & 0x1) == 0x0);
|
||||
// enter mem_mode
|
||||
HAL_SDR_WRITE32(REG_SDR_CSR, 0x600);
|
||||
#ifdef FIX_SDR_CALIBRATION
|
||||
SDR_DDL_FCTRL(TapCnt); // SDR_DDL_FCTRL(0x11);
|
||||
return 1;
|
||||
#else
|
||||
union { u8 b[8]; u16 s[4]; u32 l[2]; u64 d;} value;
|
||||
// read calibration data from system data FLASH_SDRC_PARA_BASE
|
||||
u32 reg = HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_SYSPLL_CTRL1);
|
||||
u32 faddr = SPI_FLASH_BASE + FLASH_SDRC_PARA_BASE + ((reg & 0x70) >> 1) + ((reg & BIT17) >> 11) ; // step 8 in FLASH_SDRC_PARA_BASE[64 + 64 bytes]
|
||||
value.d = *((volatile u64 *)faddr);
|
||||
DBG_8195A("SDR flash calibration [%08x] %02x-%02x-%02x\n", faddr, value.b[0], value.b[4], value.b[6]);
|
||||
if(value.s[0] == 0xFE01 && (value.b[4]^value.b[5]) == 0xFF && (value.b[6]^value.b[7]) == 0xFF) {
|
||||
HAL_SDR_WRITE32(REG_SDR_IOCR, (HAL_SDR_READ32(REG_SDR_IOCR) & 0xff) | ((u32)value.b[4] << PCTL_IOCR_RD_PIPE_BFO));
|
||||
SDR_DDL_FCTRL((u32)value.b[6]);
|
||||
if(sdr_test(7))
|
||||
return 1; // ok
|
||||
else
|
||||
DBG_8195A("Not valid SDR calibration in flash!\n");
|
||||
} else
|
||||
DBG_8195A("Error SDR calibration in flash!\n");
|
||||
if(SdrCalibration_rom()) { // Внимание: дает завышенный TapCnt !
|
||||
// DBG_8195A("SDR calibration: %02x-%02x-%02x\n", value.b[0], value.b[4], value.b[6]);
|
||||
value.s[0] = 0xFE01;
|
||||
value.b[4] = HAL_SDR_READ32(REG_SDR_IOCR) >> PCTL_IOCR_RD_PIPE_BFO;
|
||||
value.b[5] = value.b[4] ^ 0xFF;
|
||||
value.b[6] = HAL_PERI_ON_READ32(REG_PESOC_MEM_CTRL) >> BIT_SHIFT_PESOC_SDR_DDL_CTRL;
|
||||
value.b[7] = value.b[6] ^ 0xFF;
|
||||
// DBG_8195A("%08x: %02x-%02x-%02x)\n", faddr, value.b[0], value.b[4], value.b[6]);
|
||||
if((*((volatile u16 *)(faddr)) & value.s[0]) == value.s[0]
|
||||
&& (*((volatile u32 *)(faddr + 4)) & value.l[1]) == value.l[1]) {
|
||||
*((volatile u32 *)(faddr + 4)) = value.l[1];
|
||||
DBG_8195A("Write new calibration [%08x] %02x-%02x-%02x\n", faddr, value.b[0], value.b[4], value.b[6]);
|
||||
HalDelayUs(1000);
|
||||
*((volatile u16 *)(faddr)) = value.s[0];
|
||||
} else {
|
||||
DBG_8195A("Work recalibration: %02x-%02x-%02x!\n", value.b[0], value.b[4], value.b[6]);
|
||||
}
|
||||
return 2; // recalibration - ok
|
||||
} else
|
||||
DBG_8195A("SDR recalibration fail!\n");
|
||||
return 0;
|
||||
#endif // FIX_SDR_CALIBRATION
|
||||
}
|
||||
#endif // CONFIG_SDR_EN
|
||||
|
||||
/* SYSPlatformInit */
|
||||
static void INFRA_START_SECTION SYSPlatformInit(void) {
|
||||
__asm__ __volatile__ ("cpsid f\n");
|
||||
JtagOn();
|
||||
SetDebugFlgs();
|
||||
//----- SYS Init
|
||||
HAL_SYS_CTRL_WRITE32(REG_SYS_EFUSE_SYSCFG0,
|
||||
(HAL_SYS_CTRL_READ32(REG_SYS_EFUSE_SYSCFG0) & (~(BIT_MASK_SYS_EEROM_LDO_PAR_07_04 << BIT_SHIFT_SYS_EEROM_LDO_PAR_07_04))) | BIT_SYS_EEROM_LDO_PAR_07_04(6)); // & 0xF0FFFFFF | 0x6000000
|
||||
HAL_SYS_CTRL_WRITE32(REG_SYS_XTAL_CTRL1,
|
||||
(HAL_SYS_CTRL_READ32(REG_SYS_XTAL_CTRL1) & (~(BIT_MASK_SYS_XTAL_DRV_RF1 << BIT_SHIFT_SYS_XTAL_DRV_RF1))) | BIT_SYS_XTAL_DRV_RF1(1)); // & 0xFFFFFFE7 | 8;
|
||||
//----- SDIO_Device_Off
|
||||
HAL_PERI_ON_WRITE32(REG_PESOC_HCI_CLK_CTRL0,
|
||||
HAL_PERI_ON_READ32(REG_PESOC_HCI_CLK_CTRL0) & (~BIT_SOC_ACTCK_SDIO_DEV_EN));
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_HCI_COM_FUNC_EN,
|
||||
HAL_PERI_ON_READ32(REG_SOC_HCI_COM_FUNC_EN) & (~(BIT_SOC_HCI_SDIOD_ON_EN | BIT_SOC_HCI_SDIOD_OFF_EN)));
|
||||
HAL_PERI_ON_WRITE32(REG_HCI_PINMUX_CTRL,
|
||||
HAL_PERI_ON_READ32(REG_HCI_PINMUX_CTRL) & (~(BIT_HCI_SDIOD_PIN_EN)));
|
||||
//----- GPIO Adapter
|
||||
extern HAL_GPIO_ADAPTER gBoot_Gpio_Adapter;
|
||||
_memset(&gBoot_Gpio_Adapter, 0, sizeof(gBoot_Gpio_Adapter));
|
||||
_pHAL_Gpio_Adapter = &gBoot_Gpio_Adapter;
|
||||
#ifdef DEFAULT_BOOT_CLK_CPU
|
||||
//----- CLK CPU
|
||||
loguart_wait_tx_fifo_empty(); // иначе глючит LogUART, если переключение CLK приходится на вывод символов !
|
||||
#if DEFAULT_BOOT_CPU_CLOCK_SEL_DIV5_3
|
||||
// 6 - 200000000 Hz, 7 - 10000000 Hz, 8 - 50000000 Hz, 9 - 25000000 Hz, 10 - 12500000 Hz, 11 - 4000000 Hz
|
||||
HalCpuClkConfig(DEFAULT_BOOT_CPU_CLOCK_SEL_VALUE);
|
||||
*((int *)(SYSTEM_CTRL_BASE+REG_SYS_SYSPLL_CTRL1)) |= (1<<17);// REG_SYS_SYSPLL_CTRL1 |= BIT_SYS_SYSPLL_DIV5_3
|
||||
#else
|
||||
// 0 - 166666666 Hz, 1 - 83333333 Hz, 2 - 41666666 Hz, 3 - 20833333 Hz, 4 - 10416666 Hz, 5 - 4000000 Hz
|
||||
*((int *) (SYSTEM_CTRL_BASE + REG_SYS_SYSPLL_CTRL1)) &= ~(1 << 17); // REG_SYS_SYSPLL_CTRL1 &= ~BIT_SYS_SYSPLL_DIV5_3
|
||||
HalCpuClkConfig(DEFAULT_BOOT_CPU_CLOCK_SEL_VALUE);
|
||||
#endif // CPU_CLOCK_SEL_DIV5_3
|
||||
#endif // DEFAULT_CLK_CPU
|
||||
//----- System
|
||||
VectorTableInitRtl8195A(STACK_TOP); // 0x1FFFFFFC
|
||||
HalInitPlatformLogUartV02(); // Show "<RTL8195A>"... :(
|
||||
HalInitPlatformTimerV02();
|
||||
__asm__ __volatile__ ("cpsie f\n");
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------
|
||||
Копирует данные из области align(4) (flash, registers, ...) в область align(1) (ram)
|
||||
--------------------------------------------------------------------------------------*/
|
||||
static unsigned int BOOT_RAM_TEXT_SECTION flashcpy(unsigned int faddr,
|
||||
void *dist, unsigned int size) {
|
||||
union {
|
||||
unsigned char uc[4];
|
||||
unsigned int ud;
|
||||
} tmp;
|
||||
if (faddr < SPI_FLASH_BASE)
|
||||
faddr += SPI_FLASH_BASE;
|
||||
unsigned char * pd = (unsigned char *) dist;
|
||||
unsigned int *p = (unsigned int *) ((unsigned int) faddr & (~3));
|
||||
unsigned int xlen = (unsigned int) faddr & 3;
|
||||
unsigned int len = size;
|
||||
|
||||
if (xlen) {
|
||||
tmp.ud = *p++;
|
||||
while (len) {
|
||||
len--;
|
||||
*pd++ = tmp.uc[xlen++];
|
||||
if (xlen & 4)
|
||||
break;
|
||||
};
|
||||
};
|
||||
xlen = len >> 2;
|
||||
while (xlen) {
|
||||
tmp.ud = *p++;
|
||||
*pd++ = tmp.uc[0];
|
||||
*pd++ = tmp.uc[1];
|
||||
*pd++ = tmp.uc[2];
|
||||
*pd++ = tmp.uc[3];
|
||||
xlen--;
|
||||
};
|
||||
if (len & 3) {
|
||||
tmp.ud = *p;
|
||||
pd[0] = tmp.uc[0];
|
||||
if (len & 2) {
|
||||
pd[1] = tmp.uc[1];
|
||||
if (len & 1) {
|
||||
pd[2] = tmp.uc[2];
|
||||
};
|
||||
};
|
||||
};
|
||||
return size;
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
SEG_ID_ERR,
|
||||
SEG_ID_SRAM,
|
||||
SEG_ID_TCM,
|
||||
SEG_ID_SDRAM,
|
||||
SEG_ID_SOC,
|
||||
SEG_ID_FLASH,
|
||||
SEG_ID_CPU,
|
||||
SEG_ID_ROM,
|
||||
SEG_ID_MAX
|
||||
} _SEG_ID;
|
||||
|
||||
static const char * const txt_tab_seg[] = {
|
||||
"UNK", // 0
|
||||
"SRAM", // 1
|
||||
"TCM", // 2
|
||||
"SDRAM", // 3
|
||||
"SOC", // 4
|
||||
"FLASH", // 5
|
||||
"CPU", // 6
|
||||
"ROM" // 7
|
||||
};
|
||||
|
||||
static const uint32 tab_seg_def[] = { 0x10000000, 0x10070000, 0x1fff0000,
|
||||
0x20000000, 0x30000000, 0x30200000, 0x40000000, 0x40800000, 0x98000000,
|
||||
0xA0000000, 0xE0000000, 0xE0010000, 0x00000000, 0x00050000 };
|
||||
|
||||
static uint32 BOOT_RAM_TEXT_SECTION get_seg_id(uint32 addr, int32 size) {
|
||||
uint32 ret = SEG_ID_ERR;
|
||||
uint32 * ptr = (uint32 *) &tab_seg_def;
|
||||
if (size > 0) {
|
||||
do {
|
||||
ret++;
|
||||
if (addr >= ptr[0] && addr + size <= ptr[1]) {
|
||||
return ret;
|
||||
};
|
||||
ptr += 2;
|
||||
} while (ret < SEG_ID_MAX);
|
||||
};
|
||||
return 0; // UNK
|
||||
}
|
||||
|
||||
static uint32 BOOT_RAM_TEXT_SECTION load_img2_head(uint32 faddr, PIMG2HEAD hdr) {
|
||||
flashcpy(faddr, hdr, sizeof(IMG2HEAD));
|
||||
uint32 ret = get_seg_id(hdr->seg.ldaddr, hdr->seg.size);
|
||||
if (hdr->seg.sign[1] == IMG_SIGN2_RUN) {
|
||||
if (hdr->seg.sign[0] == IMG_SIGN1_RUN) {
|
||||
ret |= 1 << 9; // есть сигнатура RUN
|
||||
} else if (hdr->seg.sign[0] == IMG_SIGN1_SWP) {
|
||||
ret |= 1 << 8; // есть сигнатура SWP
|
||||
};
|
||||
}
|
||||
if (*(uint32_t *) (&hdr->rtkwin) == IMG2_SIGN_DW1_TXT) {
|
||||
ret |= 1 << 10; // есть подпись "RTKW"
|
||||
};
|
||||
return ret;
|
||||
}
|
||||
|
||||
static uint32 BOOT_RAM_TEXT_SECTION load_segs(uint32 faddr, PIMG2HEAD hdr,
|
||||
uint8 flgload) {
|
||||
uint32 fnextaddr = faddr;
|
||||
uint8 segnum = 0;
|
||||
while (1) {
|
||||
uint32 seg_id = get_seg_id(hdr->seg.ldaddr, hdr->seg.size);
|
||||
if (flgload
|
||||
&& (seg_id == SEG_ID_SRAM || seg_id == SEG_ID_TCM
|
||||
|| seg_id == SEG_ID_SDRAM)) {
|
||||
#if CONFIG_DEBUG_LOG > 1
|
||||
DBG_8195A("Load Flash seg%d: 0x%08x -> %s: 0x%08x, size: %d\n",
|
||||
segnum, faddr, txt_tab_seg[seg_id], hdr->seg.ldaddr,
|
||||
hdr->seg.size);
|
||||
#endif
|
||||
fnextaddr += flashcpy(fnextaddr, (void *)hdr->seg.ldaddr, hdr->seg.size);
|
||||
} else if (seg_id) {
|
||||
#if CONFIG_DEBUG_LOG > 2
|
||||
DBG_8195A("Skip Flash seg%d: 0x%08x -> %s: 0x%08x, size: %d\n", segnum,
|
||||
faddr, txt_tab_seg[seg_id], hdr->seg.ldaddr, hdr->seg.size);
|
||||
#endif
|
||||
fnextaddr += hdr->seg.size;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
fnextaddr += flashcpy(fnextaddr, &hdr->seg, sizeof(IMGSEGHEAD));
|
||||
segnum++;
|
||||
}
|
||||
return fnextaddr;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------
|
||||
* 0 - default image (config data + 0), 1 - image N1, 2 - image N2, ...
|
||||
--------------------------------------------------------------------------------------*/
|
||||
static int BOOT_RAM_TEXT_SECTION loadUserImges(int imgnum) {
|
||||
IMG2HEAD hdr;
|
||||
int imagenum = 1;
|
||||
uint32 faddr = 0xb000; // start image2 in flash
|
||||
DBG_8195A("Selected Image %d.\n", imgnum);
|
||||
|
||||
while (1) {
|
||||
faddr = (faddr + FLASH_SECTOR_SIZE - 1) & (~(FLASH_SECTOR_SIZE - 1));
|
||||
uint32 img_id = load_img2_head(faddr, &hdr);
|
||||
if ((img_id >> 8) > 4 && (uint8) img_id != 0) { // есть подпись "RTKW" + RUN или SWP, сегмент != unknown
|
||||
// загрузить, если imagenum == imgnum
|
||||
faddr = load_segs(faddr + 0x10, (PIMG2HEAD) &hdr.seg, imagenum == imgnum); // faddr == fnextaddr
|
||||
if (imagenum == imgnum) { // если искомая img
|
||||
// DBG_8195A("Image%d: %s\n", imgnum, hdr.name);
|
||||
break;
|
||||
}
|
||||
imagenum++; // перейти к следующей
|
||||
} else if (imagenum) { // нет подписей у заданной imgnum
|
||||
DBG_8195A("No Image%d! Trying Image0...\n", imgnum);
|
||||
// пробуем загрузить image по умолчанию, по записи в секторе установок
|
||||
flashcpy(FLASH_SYSTEM_DATA_ADDR, &faddr, sizeof(faddr));
|
||||
if (faddr < 0x8000000)
|
||||
faddr += SPI_FLASH_BASE;
|
||||
if (get_seg_id(faddr, 0x100) == SEG_ID_FLASH) { // указывает в Flash?
|
||||
// будем пробовать грузить
|
||||
imagenum = 0;
|
||||
imgnum = 0;
|
||||
} else {
|
||||
DBG_8195A("No Image0!\n");
|
||||
imagenum = -1;
|
||||
break;
|
||||
};
|
||||
} else {
|
||||
imagenum = -1; // нет записей image
|
||||
break;
|
||||
}
|
||||
};
|
||||
return imagenum;
|
||||
}
|
||||
|
||||
//----- IsForceLoadDefaultImg2
|
||||
static uint8 BOOT_RAM_TEXT_SECTION IsForceLoadDefaultImg2(void) {
|
||||
uint8 gpio_pin[4];
|
||||
HAL_GPIO_PIN GPIO_Pin;
|
||||
HAL_GPIO_PIN_STATE flg;
|
||||
int result = 0;
|
||||
flashcpy(FLASH_SYSTEM_DATA_ADDR + 0x08, &gpio_pin, sizeof(gpio_pin)); // config data + 8
|
||||
// _pHAL_Gpio_Adapter = &gBoot_Gpio_Adapter;
|
||||
for (int i = 1; i; i--) {
|
||||
uint8 x = gpio_pin[i];
|
||||
result <<= 1;
|
||||
if (x != 0xff) {
|
||||
GPIO_Pin.pin_name = HAL_GPIO_GetIPPinName_8195a(x & 0x7F);
|
||||
if (x & 0x80) {
|
||||
GPIO_Pin.pin_mode = DIN_PULL_LOW;
|
||||
flg = GPIO_PIN_HIGH;
|
||||
} else {
|
||||
GPIO_Pin.pin_mode = DIN_PULL_HIGH;
|
||||
flg = GPIO_PIN_LOW;
|
||||
}
|
||||
HAL_GPIO_Init_8195a(&GPIO_Pin);
|
||||
if (HAL_GPIO_ReadPin_8195a(&GPIO_Pin) == flg) {
|
||||
result |= 1;
|
||||
}
|
||||
HAL_GPIO_DeInit_8195a(&GPIO_Pin);
|
||||
}
|
||||
}
|
||||
// _pHAL_Gpio_Adapter->IrqHandle.IrqFun = NULL;
|
||||
return result;
|
||||
}
|
||||
|
||||
extern _LONG_CALL_ void RtlConsolTaskRom(void *Data);
|
||||
|
||||
/* RTL Console ROM */
|
||||
static void BOOT_RAM_TEXT_SECTION RtlConsolRam(void) {
|
||||
// DiagPrintf("\r\nRTL Console ROM\r\n");
|
||||
// RtlConsolInit(ROM_STAGE, (uint32_t) 6, (void*) &UartLogRomCmdTable);
|
||||
pUartLogCtl->RevdNo = UART_LOG_HISTORY_LEN;
|
||||
pUartLogCtl->BootRdy = 1;
|
||||
pUartLogCtl->pTmpLogBuf->UARTLogBuf[0] = '?';
|
||||
pUartLogCtl->pTmpLogBuf->BufCount = 1;
|
||||
pUartLogCtl->ExecuteCmd = 1;
|
||||
RtlConsolTaskRom((void *) pUartLogCtl);
|
||||
}
|
||||
|
||||
/* Enter Image 1.5 */
|
||||
static void BOOT_RAM_TEXT_SECTION EnterImage15(int flg) {
|
||||
|
||||
if (flg)
|
||||
_memset(&__rom_bss_start__, 0, &__rom_bss_end__ - &__rom_bss_start__);
|
||||
|
||||
SYSPlatformInit();
|
||||
|
||||
if (!flg)
|
||||
DBG_8195A("\r===== Enter FLASH-Boot ====\n");
|
||||
else
|
||||
DBG_8195A("\r===== Enter SRAM-Boot %d ====\n", flg);
|
||||
#if CONFIG_DEBUG_LOG > 1
|
||||
DBG_8195A("CPU CLK: %d Hz, SOC FUNC EN: %p\n", HalGetCpuClk(),
|
||||
HAL_PERI_ON_READ32(REG_SOC_FUNC_EN));
|
||||
#endif
|
||||
#ifdef CONFIG_SDR_EN
|
||||
uint8 ChipId = _Get_ChipId();
|
||||
if (ChipId < CHIP_ID_8195AM) {
|
||||
#endif
|
||||
//----- SDRAM Off
|
||||
SDR_PIN_FCTRL(OFF);
|
||||
LDO25M_CTRL(OFF);
|
||||
#ifdef CONFIG_SDR_EN
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN, HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) | BIT(21)); // Flag SDRAM Init or None
|
||||
} else {
|
||||
//----- SDRAM On
|
||||
sdr_preinit();
|
||||
};
|
||||
#endif
|
||||
if (!InitSpic(SpicDualBitMode)) {
|
||||
DBG_8195A("Spic Init fail!\n");
|
||||
RtlConsolRam();
|
||||
};
|
||||
#ifdef CONFIG_SDR_EN
|
||||
if ((HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) & BIT(21)) == 0) { // Flag SDRAM No ReInit?
|
||||
if(!sdr_init_from_flash()) {
|
||||
DBG_8195A("SDR Init fail!\n");
|
||||
RtlConsolRam();
|
||||
}
|
||||
#ifdef USE_SDRAM_TEST // Test SDRAM
|
||||
else {
|
||||
uint32 *ptr = (uint32 *)SDR_SDRAM_BASE;
|
||||
uint32 tt = 0x55AA55AA;
|
||||
for (int i = 0; i < 512 * 1024; i++) {
|
||||
ptr[i] = tt++;
|
||||
};
|
||||
tt = 0x55AA55AA;
|
||||
for (int i = 0; i < 512 * 1024; i++) {
|
||||
if (ptr[i] != tt) {
|
||||
DBG_8195A("SDR err %p %p != %p!\n", &ptr[i], ptr[i], tt);
|
||||
RtlConsolRam();
|
||||
}
|
||||
// ptr[i] = 0;
|
||||
tt++;
|
||||
};
|
||||
DBG_8195A("SDR test ok\n");
|
||||
};
|
||||
#endif // Test SDRAM
|
||||
// Тест и ожидание загрузки Jlink-ом sdram.bin (~7 sec)
|
||||
if(flg && *((uint32 *)0x1FFF0000) == 0x12345678) {
|
||||
*((volatile uint32 *)0x1FFF0000) = 0x87654321;
|
||||
uint32 tt = 0x03ffffff; // ~7 sec
|
||||
DBG_8195A("Waiting for SDRAM to load...\n");
|
||||
// __asm__ __volatile__ ("cpsid f\n");
|
||||
while(*((volatile uint32 *)0x1FFF0000) == 0x87654321 && tt--);
|
||||
// __asm__ __volatile__ ("cpsie f\n");
|
||||
if(*((volatile uint32 *)0x1FFF0000) == 1)
|
||||
DBG_8195A("SDRAM load ok\n");
|
||||
}
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN, HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) | BIT(21)); // Flag SDRAM No ReInit
|
||||
};
|
||||
#endif // CONFIG_SDR_EN
|
||||
if (!flg)
|
||||
loadUserImges(IsForceLoadDefaultImg2() + 1);
|
||||
|
||||
if (_strcmp((const char *) &__image2_validate_code__, IMG2_SIGN_TXT)) {
|
||||
DBG_8195A("Invalid Image Signature!\n");
|
||||
RtlConsolRam();
|
||||
}
|
||||
|
||||
DBG_8195A("Img Sign: %s, Go @ 0x%08x\r\n", &__image2_validate_code__,
|
||||
__image2_entry_func__);
|
||||
__image2_entry_func__();
|
||||
}
|
||||
|
||||
/* RtlBootToSram */
|
||||
static void BOOT_RAM_TEXT_SECTION RtlBoot1ToSram(void) {
|
||||
EnterImage15(1);
|
||||
}
|
||||
/* RtlBootToSram */
|
||||
static void BOOT_RAM_TEXT_SECTION RtlBoot2ToSram(void) {
|
||||
EnterImage15(2);
|
||||
}
|
||||
/* RtlBootToSram */
|
||||
static void BOOT_RAM_TEXT_SECTION RtlBoot3ToSram(void) {
|
||||
EnterImage15(3);
|
||||
}
|
||||
/* RtlBootToSram */
|
||||
static void BOOT_RAM_TEXT_SECTION RtlBoot4ToSram(void) {
|
||||
EnterImage15(4);
|
||||
}
|
||||
|
||||
static void BOOT_RAM_TEXT_SECTION RtlBootToFlash(void) {
|
||||
EnterImage15(0);
|
||||
}
|
||||
|
|
@ -0,0 +1,387 @@
|
|||
/*
|
||||
* (SRAM) Debug BootLoader
|
||||
* Created on: 12/02/2017
|
||||
* Author: pvvx
|
||||
*/
|
||||
|
||||
#include "platform_autoconf.h"
|
||||
#include "rtl_bios_data.h"
|
||||
#include "diag.h"
|
||||
#include "rtl8195a/rtl8195a_sys_on.h"
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Data declarations
|
||||
//extern uint32_t STACK_TOP;
|
||||
//extern volatile UART_LOG_CTL * pUartLogCtl;
|
||||
#ifndef DEFAULT_BAUDRATE
|
||||
#define DEFAULT_BAUDRATE UART_BAUD_RATE_38400
|
||||
#endif
|
||||
|
||||
#define BOOT_RAM_TEXT_SECTION // __attribute__((section(".boot.text")))
|
||||
//#define BOOT_RAM_RODATA_SECTION __attribute__((section(".boot.rodata")))
|
||||
//#define BOOT_RAM_DATA_SECTION __attribute__((section(".boot.data")))
|
||||
//#define BOOT_RAM_BSS_SECTION __attribute__((section(".boot.bss")))
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
typedef struct _seg_header {
|
||||
uint32 size;
|
||||
uint32 ldaddr;
|
||||
} IMGSEGHEAD, *PIMGSEGHEAD;
|
||||
|
||||
typedef struct _img2_header {
|
||||
IMGSEGHEAD seg;
|
||||
uint32 sign[2];
|
||||
void (*startfunc)(void);
|
||||
uint8 rtkwin[7];
|
||||
uint8 ver[13];
|
||||
uint8 name[32];
|
||||
} IMG2HEAD, *PIMG2HEAD;
|
||||
|
||||
#ifndef FLASH_SECTOR_SIZE
|
||||
#define FLASH_SECTOR_SIZE 4096
|
||||
#endif
|
||||
//-------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
static void RtlBootToFlash(void); // image1
|
||||
static void RtlBootToSram(void); // image1
|
||||
static void EnterImage15(void); // image1
|
||||
static void JtagOn(void); // image1
|
||||
|
||||
extern _LONG_CALL_ void HalCpuClkConfig(unsigned char CpuType);
|
||||
extern _LONG_CALL_ void VectorTableInitRtl8195A(uint32_t StackP);
|
||||
extern _LONG_CALL_ void HalInitPlatformLogUartV02(void);
|
||||
extern _LONG_CALL_ void HalInitPlatformTimerV02(void);
|
||||
|
||||
//#pragma arm section code = ".boot.text";
|
||||
//#pragma arm section rodata = ".boot.rodata", rwdata = ".boot.data", zidata = ".boot.bss";
|
||||
|
||||
typedef void (*START_FUNC)(void);
|
||||
|
||||
/* Start table: */
|
||||
START_RAM_FUN_SECTION RAM_FUNCTION_START_TABLE __ram_start_table_start__ = {
|
||||
RtlBootToFlash + 1, // StartFun(), Run if ( v400001F4 & 0x8000000 ) && ( v40000210 & 0x80000000 )
|
||||
RtlBootToSram + 1, // PatchWAKE(), Run if ( v40000210 & 0x20000000 )
|
||||
RtlBootToSram + 1, // PatchFun0(), Run if ( v40000210 & 0x10000000 )
|
||||
RtlBootToSram + 1,// PatchFun1(), Run if ( v400001F4 & 0x8000000 ) && ( v40000210 & 0x8000000 )
|
||||
RtlBootToFlash + 1 };// PatchFun2(), Run for Init console, if ( v40000210 & 0x4000000 )
|
||||
// EnterImage15 + 1}; // PatchFun2(), Run for Init console, if ( v40000210 & 0x4000000 )
|
||||
|
||||
/* Set Debug Flags */
|
||||
static void BOOT_RAM_TEXT_SECTION SetDebugFlgs() {
|
||||
#if CONFIG_DEBUG_LOG > 3
|
||||
CfgSysDebugWarn = -1;
|
||||
CfgSysDebugInfo = -1;
|
||||
CfgSysDebugErr = -1;
|
||||
ConfigDebugWarn = -1;
|
||||
ConfigDebugInfo = -1;
|
||||
ConfigDebugErr = -1;
|
||||
#elif CONFIG_DEBUG_LOG > 1
|
||||
CfgSysDebugWarn = -1;
|
||||
// CfgSysDebugInfo = 0;
|
||||
CfgSysDebugErr = -1;
|
||||
ConfigDebugWarn = -1;
|
||||
// ConfigDebugInfo = 0;
|
||||
ConfigDebugErr = -1;
|
||||
#elif CONFIG_DEBUG_LOG > 0
|
||||
// CfgSysDebugWarn = 0;
|
||||
// CfgSysDebugInfo = 0;
|
||||
CfgSysDebugErr = -1;
|
||||
// ConfigDebugWarn = 0;
|
||||
// ConfigDebugInfo = 0;
|
||||
ConfigDebugErr = -1;
|
||||
#else
|
||||
// CfgSysDebugWarn = 0;
|
||||
// CfgSysDebugInfo = 0;
|
||||
// CfgSysDebugErr = 0;
|
||||
// ConfigDebugWarn = 0;
|
||||
// ConfigDebugInfo = 0;
|
||||
// ConfigDebugErr = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* RTL Console ROM */
|
||||
static void BOOT_RAM_TEXT_SECTION RtlConsolRam(void) {
|
||||
// DiagPrintf("\r\nRTL Console ROM\r\n");
|
||||
pUartLogCtl->pTmpLogBuf->UARTLogBuf[0] = '?';
|
||||
pUartLogCtl->pTmpLogBuf->BufCount = 1;
|
||||
pUartLogCtl->ExecuteCmd = 1;
|
||||
RtlConsolTaskRom(pUartLogCtl);
|
||||
}
|
||||
|
||||
/* JTAG On */
|
||||
static void BOOT_RAM_TEXT_SECTION JtagOn(void) {
|
||||
ACTCK_VENDOR_CCTRL(ON);
|
||||
SLPCK_VENDOR_CCTRL(ON);
|
||||
HalPinCtrlRtl8195A(JTAG, 0, 1);
|
||||
}
|
||||
|
||||
/* Enter Image 1.5 */
|
||||
static void BOOT_RAM_TEXT_SECTION EnterImage15(void) {
|
||||
SetDebugFlgs();
|
||||
DBG_8195A(
|
||||
"\n===== Enter SRAM-Boot ====\nImg Sign: %s, Go @ 0x%08x\r\n",
|
||||
&__image2_validate_code__, __image2_entry_func__);
|
||||
#if CONFIG_DEBUG_LOG > 2
|
||||
DBG_8195A("CPU CLK: %d Hz, SOC FUNC EN: %p\r\n", HalGetCpuClk(),
|
||||
HAL_PERI_ON_READ32(REG_SOC_FUNC_EN));
|
||||
#endif
|
||||
if (_strcmp((const char *) &__image2_validate_code__, IMG2_SIGN_TXT)) {
|
||||
DBG_MISC_ERR("Invalid Image Signature!\n");
|
||||
RtlConsolRam();
|
||||
}
|
||||
__image2_entry_func__();
|
||||
}
|
||||
|
||||
/* RtlBootToSram */
|
||||
static void BOOT_RAM_TEXT_SECTION RtlBootToSram(void) {
|
||||
JtagOn(); /* JTAG On */
|
||||
_memset(&__rom_bss_start__, 0, &__rom_bss_end__ - &__rom_bss_start__);
|
||||
__asm__ __volatile__ ("cpsid f\n");
|
||||
HAL_SYS_CTRL_WRITE32(REG_SYS_SYSPLL_CTRL1,
|
||||
HAL_SYS_CTRL_READ32(REG_SYS_SYSPLL_CTRL1) & ( ~BIT_SYS_SYSPLL_DIV5_3));
|
||||
HalCpuClkConfig(2); // 41.666666 MHz
|
||||
// HAL_SYS_CTRL_WRITE32(REG_SYS_SYSPLL_CTRL1, HAL_SYS_CTRL_READ32(REG_SYS_SYSPLL_CTRL1) | BIT_SYS_SYSPLL_DIV5_3); // 50.000 MHz
|
||||
VectorTableInitRtl8195A(STACK_TOP); // 0x1FFFFFFC
|
||||
HalInitPlatformLogUartV02();
|
||||
HalInitPlatformTimerV02();
|
||||
__asm__ __volatile__ ("cpsie f\n");
|
||||
// SdrPowerOff();
|
||||
SDR_PIN_FCTRL(OFF);
|
||||
LDO25M_CTRL(OFF);
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN,
|
||||
HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) | BIT(21));
|
||||
|
||||
SpicInitRtl8195AV02(1, 0); // StartupSpicBaudRate InitBaudRate 1, SpicBitMode 1 StartupSpicBitMode
|
||||
EnterImage15();
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------
|
||||
Копирует данные из области align(4) (flash, registers, ...) в область align(1) (ram)
|
||||
--------------------------------------------------------------------------------------*/
|
||||
static unsigned int BOOT_RAM_TEXT_SECTION flashcpy(unsigned int faddr,
|
||||
void *dist, unsigned int size) {
|
||||
union {
|
||||
unsigned char uc[4];
|
||||
unsigned int ud;
|
||||
} tmp;
|
||||
if (faddr < SPI_FLASH_BASE)
|
||||
faddr += SPI_FLASH_BASE;
|
||||
unsigned char * pd = (unsigned char *) dist;
|
||||
unsigned int *p = (unsigned int *) ((unsigned int) faddr & (~3));
|
||||
unsigned int xlen = (unsigned int) faddr & 3;
|
||||
unsigned int len = size;
|
||||
|
||||
if (xlen) {
|
||||
tmp.ud = *p++;
|
||||
while (len) {
|
||||
len--;
|
||||
*pd++ = tmp.uc[xlen++];
|
||||
if (xlen & 4)
|
||||
break;
|
||||
};
|
||||
};
|
||||
xlen = len >> 2;
|
||||
while (xlen) {
|
||||
tmp.ud = *p++;
|
||||
*pd++ = tmp.uc[0];
|
||||
*pd++ = tmp.uc[1];
|
||||
*pd++ = tmp.uc[2];
|
||||
*pd++ = tmp.uc[3];
|
||||
xlen--;
|
||||
};
|
||||
if (len & 3) {
|
||||
tmp.ud = *p;
|
||||
pd[0] = tmp.uc[0];
|
||||
if (len & 2) {
|
||||
pd[1] = tmp.uc[1];
|
||||
if (len & 1) {
|
||||
pd[2] = tmp.uc[2];
|
||||
};
|
||||
};
|
||||
};
|
||||
return size;
|
||||
}
|
||||
|
||||
enum {
|
||||
SEG_ID_ERR,
|
||||
SEG_ID_SRAM,
|
||||
SEG_ID_TCM,
|
||||
SEG_ID_SDRAM,
|
||||
SEG_ID_SOC,
|
||||
SEG_ID_FLASH,
|
||||
SEG_ID_CPU,
|
||||
SEG_ID_ROM,
|
||||
SEG_ID_MAX
|
||||
} SEG_ID;
|
||||
|
||||
static const char * const txt_tab_seg[] = {
|
||||
"UNK", // 0
|
||||
"SRAM", // 1
|
||||
"TCM", // 2
|
||||
"SDRAM", // 3
|
||||
"SOC", // 4
|
||||
"FLASH", // 5
|
||||
"CPU", // 6
|
||||
"ROM" // 7
|
||||
};
|
||||
|
||||
static const uint32 tab_seg_def[] = { 0x10000000, 0x10070000, 0x1fff0000,
|
||||
0x20000000, 0x30000000, 0x30200000, 0x40000000, 0x40800000, 0x98000000,
|
||||
0xA0000000, 0xE0000000, 0xE0010000, 0x00000000, 0x00050000 };
|
||||
|
||||
static uint32 BOOT_RAM_TEXT_SECTION get_seg_id(uint32 addr, int32 size) {
|
||||
uint32 ret = SEG_ID_ERR;
|
||||
uint32 * ptr = &tab_seg_def;
|
||||
if (size > 0) {
|
||||
do {
|
||||
ret++;
|
||||
if (addr >= ptr[0] && addr + size <= ptr[1]) {
|
||||
return ret;
|
||||
};
|
||||
ptr += 2;
|
||||
} while (ret < SEG_ID_MAX);
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint32 BOOT_RAM_TEXT_SECTION load_img2_head(uint32 faddr, PIMG2HEAD hdr) {
|
||||
flashcpy(faddr, hdr, sizeof(IMG2HEAD));
|
||||
uint32 ret = get_seg_id(hdr->seg.ldaddr, hdr->seg.size);
|
||||
if (hdr->sign[1] == IMG_SIGN2_RUN) {
|
||||
if (hdr->sign[0] == IMG_SIGN1_RUN) {
|
||||
ret |= 1 << 9;
|
||||
} else if (hdr->sign[0] == IMG_SIGN1_SWP) {
|
||||
ret |= 1 << 8;
|
||||
};
|
||||
}
|
||||
if (*(uint32_t *) (&hdr->rtkwin) == IMG2_SIGN_DW1_TXT) {
|
||||
ret |= 1 << 10;
|
||||
};
|
||||
return ret;
|
||||
}
|
||||
|
||||
static uint32 BOOT_RAM_TEXT_SECTION load_segs(uint32 faddr, PIMG2HEAD hdr,
|
||||
uint8 flgload) {
|
||||
uint32 fnextaddr = faddr;
|
||||
uint8 segnum = 0;
|
||||
while (1) {
|
||||
uint32 seg_id = get_seg_id(hdr->seg.ldaddr, hdr->seg.size);
|
||||
if (flgload && (seg_id == SEG_ID_SRAM || seg_id == SEG_ID_TCM)) {
|
||||
#if CONFIG_DEBUG_LOG > 1
|
||||
DBG_8195A("Load Flash seg%d: 0x%08x -> %s: 0x%08x, size: %d\n",
|
||||
segnum, faddr, txt_tab_seg[seg_id], hdr->seg.ldaddr,
|
||||
hdr->seg.size);
|
||||
#endif
|
||||
fnextaddr += flashcpy(fnextaddr, hdr->seg.ldaddr, hdr->seg.size);
|
||||
} else if (seg_id) {
|
||||
#if CONFIG_DEBUG_LOG > 2
|
||||
DBG_8195A("Skip Flash seg%d: 0x%08x -> %s: 0x%08x, size: %d\n", segnum,
|
||||
faddr, txt_tab_seg[seg_id], hdr->seg.ldaddr, hdr->seg.size);
|
||||
#endif
|
||||
fnextaddr += hdr->seg.size;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
fnextaddr += flashcpy(fnextaddr, &hdr->seg, sizeof(IMGSEGHEAD));
|
||||
segnum++;
|
||||
}
|
||||
return fnextaddr;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------
|
||||
* 0 - default image (config data + 0), 1 - image N1, 2 - image N2, ...
|
||||
--------------------------------------------------------------------------------------*/
|
||||
static int BOOT_RAM_TEXT_SECTION loadUserImges(int imgnum) {
|
||||
IMG2HEAD hdr;
|
||||
int imagenum = 1;
|
||||
uint32 faddr = 0xb000; // start image2 in flash
|
||||
DBG_8195A("Selected Image %d.\n", imgnum);
|
||||
|
||||
while (1) {
|
||||
faddr = (faddr + FLASH_SECTOR_SIZE - 1) & (~(FLASH_SECTOR_SIZE - 1));
|
||||
uint32 img_id = load_img2_head(faddr, &hdr);
|
||||
if ((img_id >> 8) > 4 || (uint8) img_id != 0) {
|
||||
faddr = load_segs(faddr + 0x10, &hdr.seg, imagenum == imgnum);
|
||||
if (imagenum == imgnum) {
|
||||
// DBG_8195A("Image%d: %s\n", imgnum, hdr.name);
|
||||
break;
|
||||
}
|
||||
imagenum++;
|
||||
} else if (imagenum) {
|
||||
DBG_8195A("No Image%d! Trying Image0...\n", imgnum);
|
||||
// пробуем загрузить image по умолчанию, по записи в секторе установок
|
||||
flashcpy(FLASH_SYSTEM_DATA_ADDR, &faddr, sizeof(faddr));
|
||||
if (faddr < 0x8000000)
|
||||
faddr += SPI_FLASH_BASE;
|
||||
if (get_seg_id(faddr, 0x100) == SEG_ID_FLASH) {
|
||||
imagenum = 0;
|
||||
imgnum = 0;
|
||||
} else {
|
||||
DBG_8195A("No Image0!\n");
|
||||
imagenum = -1;
|
||||
break;
|
||||
};
|
||||
} else {
|
||||
imagenum = -1;
|
||||
break;
|
||||
}
|
||||
};
|
||||
return imagenum;
|
||||
}
|
||||
;
|
||||
|
||||
extern PHAL_GPIO_ADAPTER _pHAL_Gpio_Adapter;
|
||||
extern HAL_GPIO_ADAPTER gBoot_Gpio_Adapter;
|
||||
//----- IsForceLoadDefaultImg2
|
||||
static uint8 BOOT_RAM_TEXT_SECTION IsForceLoadDefaultImg2(void) {
|
||||
uint8 gpio_pin[4];
|
||||
HAL_GPIO_PIN GPIO_Pin;
|
||||
HAL_GPIO_PIN_STATE flg;
|
||||
int result = 0;
|
||||
flashcpy(FLASH_SYSTEM_DATA_ADDR + 0x08, &gpio_pin, sizeof(gpio_pin)); // config data + 8
|
||||
_pHAL_Gpio_Adapter = &gBoot_Gpio_Adapter;
|
||||
for (int i = 1; i; i--) {
|
||||
uint8 x = gpio_pin[i];
|
||||
result <<= 1;
|
||||
if (x != 0xff) {
|
||||
GPIO_Pin.pin_name = HAL_GPIO_GetIPPinName_8195a(x & 0x7F);
|
||||
if (x & 0x80) {
|
||||
GPIO_Pin.pin_mode = DIN_PULL_LOW;
|
||||
flg = GPIO_PIN_HIGH;
|
||||
} else {
|
||||
GPIO_Pin.pin_mode = DIN_PULL_HIGH;
|
||||
flg = GPIO_PIN_LOW;
|
||||
}
|
||||
HAL_GPIO_Init_8195a(&GPIO_Pin);
|
||||
if (HAL_GPIO_ReadPin_8195a(&GPIO_Pin) == flg) {
|
||||
result |= 1;
|
||||
}
|
||||
HAL_GPIO_DeInit_8195a(&GPIO_Pin);
|
||||
}
|
||||
}
|
||||
_pHAL_Gpio_Adapter->IrqHandle.IrqFun = NULL;
|
||||
return result;
|
||||
}
|
||||
|
||||
static void BOOT_RAM_TEXT_SECTION RtlBootToFlash(void) {
|
||||
|
||||
JtagOn(); /* JTAG On */
|
||||
SetDebugFlgs();
|
||||
DBG_8195A("===== Enter FLASH-Boot ====\n");
|
||||
if (HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) & (1 << BIT_SOC_FLASH_EN)) {
|
||||
SPI_FLASH_PIN_FCTRL(ON);
|
||||
/*
|
||||
if(!SpicCmpDataForCalibrationRtl8195A()) {
|
||||
DBG_8195A("ReInit Spic DIO...\n");
|
||||
SpicInitRtl8195AV02(1, SpicDualBitMode);
|
||||
}
|
||||
*/
|
||||
loadUserImges(IsForceLoadDefaultImg2() + 1);
|
||||
};
|
||||
if (_strcmp((const char *) &__image2_validate_code__, IMG2_SIGN_TXT)) {
|
||||
DBG_8195A("Invalid Image Signature!\n");
|
||||
RtlConsolRam();
|
||||
} else
|
||||
DBG_8195A("Go @ 0x%08x\r\n", __image2_entry_func__);
|
||||
__image2_entry_func__();
|
||||
}
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
/*
|
||||
* (SRAM) Debug BootLoader
|
||||
* Created on: 12/02/2017
|
||||
* Author: pvvx
|
||||
*/
|
||||
|
||||
#include "platform_autoconf.h"
|
||||
#include "rtl_bios_data.h"
|
||||
#include "diag.h"
|
||||
#include "rtl8195a/rtl8195a_sys_on.h"
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Data declarations
|
||||
//extern uint32_t STACK_TOP;
|
||||
//extern volatile UART_LOG_CTL * pUartLogCtl;
|
||||
|
||||
#ifndef DEFAULT_BAUDRATE
|
||||
#define DEFAULT_BAUDRATE UART_BAUD_RATE_38400
|
||||
#endif
|
||||
|
||||
#define BOOT_RAM_TEXT_SECTION // __attribute__((section(".boot.text")))
|
||||
//#define BOOT_RAM_RODATA_SECTION __attribute__((section(".boot.rodata")))
|
||||
//#define BOOT_RAM_DATA_SECTION __attribute__((section(".boot.data")))
|
||||
//#define BOOT_RAM_BSS_SECTION __attribute__((section(".boot.bss")))
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
static void RtlBootToSram(void); // image1
|
||||
static void EnterImage15(void); // image1
|
||||
static void JtagOn(void); // image1
|
||||
|
||||
extern _LONG_CALL_ void HalCpuClkConfig(unsigned char CpuType);
|
||||
extern _LONG_CALL_ void VectorTableInitRtl8195A(uint32_t StackP);
|
||||
extern _LONG_CALL_ void HalInitPlatformLogUartV02(void);
|
||||
extern _LONG_CALL_ void HalInitPlatformTimerV02(void);
|
||||
|
||||
//#pragma arm section code = ".boot.text";
|
||||
//#pragma arm section rodata = ".boot.rodata", rwdata = ".boot.data", zidata = ".boot.bss";
|
||||
|
||||
typedef void (*START_FUNC)(void);
|
||||
|
||||
/* Start table: */
|
||||
START_RAM_FUN_SECTION RAM_FUNCTION_START_TABLE __ram_start_table_start__ = {
|
||||
RtlBootToSram + 1, // StartFun(), Run if ( v400001F4 & 0x8000000 ) && ( v40000210 & 0x80000000 )
|
||||
RtlBootToSram + 1, // PatchWAKE(), Run if ( v40000210 & 0x20000000 )
|
||||
RtlBootToSram + 1, //- PatchFun0(), Run if ( v40000210 & 0x10000000 )
|
||||
RtlBootToSram + 1, //+ PatchFun1(), Run if ( v400001F4 & 0x8000000 ) && ( v40000210 & 0x8000000 )
|
||||
EnterImage15 + 1}; // PatchFun2(), Run for Init console, if ( v40000210 & 0x4000000 )
|
||||
|
||||
/* Set Debug Flags */
|
||||
static void BOOT_RAM_TEXT_SECTION SetDebugFlgs() {
|
||||
#if CONFIG_DEBUG_LOG > 3
|
||||
CfgSysDebugWarn = -1;
|
||||
CfgSysDebugInfo = -1;
|
||||
CfgSysDebugErr = -1;
|
||||
ConfigDebugWarn = -1;
|
||||
ConfigDebugInfo = -1;
|
||||
ConfigDebugErr = -1;
|
||||
#elif CONFIG_DEBUG_LOG > 1
|
||||
CfgSysDebugWarn = -1;
|
||||
// CfgSysDebugInfo = 0;
|
||||
CfgSysDebugErr = -1;
|
||||
ConfigDebugWarn = -1;
|
||||
// ConfigDebugInfo = 0;
|
||||
ConfigDebugErr = -1;
|
||||
#elif CONFIG_DEBUG_LOG > 0
|
||||
// CfgSysDebugWarn = 0;
|
||||
// CfgSysDebugInfo = 0;
|
||||
CfgSysDebugErr = -1;
|
||||
// ConfigDebugWarn = 0;
|
||||
// ConfigDebugInfo = 0;
|
||||
ConfigDebugErr = -1;
|
||||
#else
|
||||
// CfgSysDebugWarn = 0;
|
||||
// CfgSysDebugInfo = 0;
|
||||
// CfgSysDebugErr = 0;
|
||||
// ConfigDebugWarn = 0;
|
||||
// ConfigDebugInfo = 0;
|
||||
// ConfigDebugErr = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* RTL Console ROM */
|
||||
static void BOOT_RAM_TEXT_SECTION RtlConsolRam(void) {
|
||||
// DiagPrintf("\r\nRTL Console ROM\r\n");
|
||||
pUartLogCtl->pTmpLogBuf->UARTLogBuf[0] = '?';
|
||||
pUartLogCtl->pTmpLogBuf->BufCount = 1;
|
||||
pUartLogCtl->ExecuteCmd = 1;
|
||||
RtlConsolTaskRom(pUartLogCtl);
|
||||
}
|
||||
|
||||
/* JTAG On */
|
||||
static void BOOT_RAM_TEXT_SECTION JtagOn(void) {
|
||||
ACTCK_VENDOR_CCTRL(ON);
|
||||
SLPCK_VENDOR_CCTRL(ON);
|
||||
HalPinCtrlRtl8195A(JTAG, 0, 1);
|
||||
}
|
||||
|
||||
/* Enter Image 1.5 */
|
||||
static void BOOT_RAM_TEXT_SECTION EnterImage15(void) {
|
||||
SetDebugFlgs();
|
||||
DBG_8195A("\rCPU CLK: %d Hz, SOC FUNC EN: %p\r\n", HalGetCpuClk(), HAL_PERI_ON_READ32(REG_SOC_FUNC_EN));
|
||||
DBG_8195A("==!== Enter Image 1.5 ====\nImg2 Sign: %s, InfaStart @ 0x%08x\r\n",
|
||||
&__image2_validate_code__, __image2_entry_func__);
|
||||
if (_strcmp((const char *) &__image2_validate_code__, IMG2_SIGN_TXT)) {
|
||||
DBG_MISC_ERR("Invalid Image2 Signature!\n");
|
||||
RtlConsolRam();
|
||||
}
|
||||
__image2_entry_func__();
|
||||
}
|
||||
|
||||
/* RtlBootToSram */
|
||||
static void BOOT_RAM_TEXT_SECTION RtlBootToSram(void) {
|
||||
JtagOn(); /* JTAG On */
|
||||
_memset(&__rom_bss_start__, 0, &__rom_bss_end__ - &__rom_bss_start__);
|
||||
__asm__ __volatile__ ("cpsid f\n");
|
||||
HAL_SYS_CTRL_WRITE32(REG_SYS_SYSPLL_CTRL1, HAL_SYS_CTRL_READ32(REG_SYS_SYSPLL_CTRL1) & ( ~BIT_SYS_SYSPLL_DIV5_3));
|
||||
HalCpuClkConfig(2); // 41.666666 MHz
|
||||
// HAL_SYS_CTRL_WRITE32(REG_SYS_SYSPLL_CTRL1, HAL_SYS_CTRL_READ32(REG_SYS_SYSPLL_CTRL1) | BIT_SYS_SYSPLL_DIV5_3); // 50.000 MHz
|
||||
VectorTableInitRtl8195A(STACK_TOP); // 0x1FFFFFFC
|
||||
HalInitPlatformLogUartV02();
|
||||
HalInitPlatformTimerV02();
|
||||
__asm__ __volatile__ ("cpsie f\n");
|
||||
SpicInitRtl8195AV02(1, 0); // StartupSpicBaudRate InitBaudRate 1, SpicBitMode 1 StartupSpicBitMode
|
||||
// HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN, HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) & 0x1FFFFF); // Clear debug flags
|
||||
EnterImage15();
|
||||
}
|
||||
|
|
@ -0,0 +1,696 @@
|
|||
/*
|
||||
* BootLoader
|
||||
* Created on: 12/02/2017
|
||||
* Author: pvvx
|
||||
*/
|
||||
|
||||
#include "platform_autoconf.h"
|
||||
#include "rtl_bios_data.h"
|
||||
#include "diag.h"
|
||||
#include "rtl8195a/rtl8195a_sys_on.h"
|
||||
|
||||
#include "hal_spi_flash.h"
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Data declarations
|
||||
|
||||
#ifndef DEFAULT_BAUDRATE
|
||||
#define DEFAULT_BAUDRATE UART_BAUD_RATE_38400
|
||||
#endif
|
||||
|
||||
/* 0 - 166666666 Hz, 1 - 83333333 Hz, 2 - 41666666 Hz, 3 - 20833333 Hz, 4 - 10416666 Hz, 5 - 4000000? Hz,
|
||||
6 - 200000000 Hz, 7 - 10000000 Hz, 8 - 50000000 Hz, 9 - 25000000 Hz, 10 - 12500000 Hz, 11 - 4000000? Hz */
|
||||
#define DEFAULT_BOOT_CLK_CPU 8 // Warning! If Start CLK > 100 MHz -> Errors SPIC function in Ameba SDK!
|
||||
|
||||
#ifdef DEFAULT_BOOT_CLK_CPU
|
||||
#if DEFAULT_BOOT_CLK_CPU < 6
|
||||
#define DEFAULT_BOOT_CPU_CLOCK_SEL_DIV5_3 0
|
||||
#define DEFAULT_BOOT_CPU_CLOCK_SEL_VALUE DEFAULT_BOOT_CLK_CPU
|
||||
#else
|
||||
#define DEFAULT_BOOT_CPU_CLOCK_SEL_DIV5_3 1
|
||||
#define DEFAULT_BOOT_CPU_CLOCK_SEL_VALUE (DEFAULT_BOOT_CLK_CPU-6)
|
||||
#endif
|
||||
#endif // DEFAULT_BOOT_CLK_CPU
|
||||
|
||||
#define BOOT_RAM_TEXT_SECTION // __attribute__((section(".boot.text")))
|
||||
//#define BOOT_RAM_RODATA_SECTION __attribute__((section(".boot.rodata")))
|
||||
//#define BOOT_RAM_DATA_SECTION __attribute__((section(".boot.data")))
|
||||
//#define BOOT_RAM_BSS_SECTION __attribute__((section(".boot.bss")))
|
||||
|
||||
//extern uint32_t STACK_TOP;
|
||||
//extern volatile UART_LOG_CTL * pUartLogCtl;
|
||||
extern void * UartLogRomCmdTable;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
typedef struct _seg_header {
|
||||
uint32 size;
|
||||
uint32 ldaddr;
|
||||
} IMGSEGHEAD, *PIMGSEGHEAD;
|
||||
|
||||
typedef struct _img2_header {
|
||||
IMGSEGHEAD seg;
|
||||
uint32 sign[2];
|
||||
void (*startfunc)(void);
|
||||
uint8 rtkwin[7];
|
||||
uint8 ver[13];
|
||||
uint8 name[32];
|
||||
} IMG2HEAD, *PIMG2HEAD;
|
||||
|
||||
#ifndef FLASH_SECTOR_SIZE
|
||||
#define FLASH_SECTOR_SIZE 4096
|
||||
#endif
|
||||
//-------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
static void RtlBootToFlash(void); // image1
|
||||
static void RtlBoot1ToSram(void); // image1
|
||||
static void RtlBoot2ToSram(void); // image1
|
||||
static void RtlBoot3ToSram(void); // image1
|
||||
static void RtlBoot4ToSram(void); // image1
|
||||
//static void EnterImage15(void); // image1
|
||||
//static void JtagOn(void); // image1
|
||||
|
||||
extern _LONG_CALL_ void HalCpuClkConfig(unsigned char CpuType);
|
||||
extern _LONG_CALL_ void VectorTableInitRtl8195A(uint32_t StackP);
|
||||
extern _LONG_CALL_ void HalInitPlatformLogUartV02(void);
|
||||
extern _LONG_CALL_ void HalInitPlatformTimerV02(void);
|
||||
//extern _LONG_CALL_ void DramInit_rom(IN DRAM_DEVICE_INFO *DramInfo);
|
||||
//extern _LONG_CALL_ uint32_t SdrCalibration_rom(void);
|
||||
extern _LONG_CALL_ int SdrControllerInit_rom(PDRAM_DEVICE_INFO pDramInfo);
|
||||
extern _LONG_CALL_ uint32_t SpicCmpDataForCalibrationRtl8195A(void); // compare read_data and golden_data
|
||||
extern _LONG_CALL_ void SpicWaitWipDoneRtl8195A(SPIC_INIT_PARA SpicInitPara); // wait spi-flash status register[0] = 0
|
||||
extern _LONG_CALL_ void SpicLoadInitParaFromClockRtl8195A(uint8_t CpuClkMode, uint8_t BaudRate, PSPIC_INIT_PARA pSpicInitPara);
|
||||
extern _LONG_CALL_ void RtlConsolInit(IN uint32_t Boot, IN uint32_t TBLSz, IN void *pTBL);
|
||||
|
||||
//#pragma arm section code = ".boot.text";
|
||||
//#pragma arm section rodata = ".boot.rodata", rwdata = ".boot.data", zidata = ".boot.bss";
|
||||
|
||||
typedef void (*START_FUNC)(void);
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
/* Start table: */
|
||||
START_RAM_FUN_SECTION RAM_FUNCTION_START_TABLE __ram_start_table_start__ = {
|
||||
RtlBootToFlash + 1, // StartFun(), Run if ( v400001F4 & 0x8000000 ) && ( v40000210 & 0x80000000 )
|
||||
RtlBoot1ToSram + 1, // PatchWAKE(), Run if ( v40000210 & 0x20000000 )
|
||||
RtlBoot2ToSram + 1, // PatchFun0(), Run if ( v40000210 & 0x10000000 )
|
||||
RtlBoot3ToSram + 1, // PatchFun1(), Run if ( v400001F4 & 0x8000000 ) && ( v40000210 & 0x8000000 )
|
||||
RtlBoot4ToSram + 1 };// PatchFun2(), Run for Init console, if ( v40000210 & 0x4000000 )
|
||||
//test RtlBootToFlash + 1 };// PatchFun2(), Run for Init console, if ( v40000210 & 0x4000000 )
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
/* Set Debug Flags */
|
||||
static void BOOT_RAM_TEXT_SECTION SetDebugFlgs() {
|
||||
#if CONFIG_DEBUG_LOG > 3
|
||||
CfgSysDebugWarn = -1;
|
||||
CfgSysDebugInfo = -1;
|
||||
CfgSysDebugErr = -1;
|
||||
ConfigDebugWarn = -1;
|
||||
ConfigDebugInfo = -1;
|
||||
ConfigDebugErr = -1;
|
||||
#elif CONFIG_DEBUG_LOG > 1
|
||||
CfgSysDebugWarn = -1;
|
||||
// CfgSysDebugInfo = 0;
|
||||
CfgSysDebugErr = -1;
|
||||
ConfigDebugWarn = -1;
|
||||
// ConfigDebugInfo = 0;
|
||||
ConfigDebugErr = -1;
|
||||
#elif CONFIG_DEBUG_LOG > 0
|
||||
// CfgSysDebugWarn = 0;
|
||||
// CfgSysDebugInfo = 0;
|
||||
CfgSysDebugErr = -1;
|
||||
// ConfigDebugWarn = 0;
|
||||
// ConfigDebugInfo = 0;
|
||||
ConfigDebugErr = -1;
|
||||
#else
|
||||
// CfgSysDebugWarn = 0;
|
||||
// CfgSysDebugInfo = 0;
|
||||
// CfgSysDebugErr = 0;
|
||||
// ConfigDebugWarn = 0;
|
||||
// ConfigDebugInfo = 0;
|
||||
// ConfigDebugErr = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* JTAG On */
|
||||
static void BOOT_RAM_TEXT_SECTION JtagOn(void) {
|
||||
ACTCK_VENDOR_CCTRL(ON);
|
||||
SLPCK_VENDOR_CCTRL(ON);
|
||||
HalPinCtrlRtl8195A(JTAG, 0, 1);
|
||||
}
|
||||
|
||||
/* GetChipId() */
|
||||
static uint8 INFRA_START_SECTION _Get_ChipId() {
|
||||
uint8 ChipId = CHIP_ID_8710AF;
|
||||
if (HALEFUSEOneByteReadROM(HAL_SYS_CTRL_READ32(REG_SYS_EFUSE_CTRL), 0xF8,
|
||||
&ChipId, L25EOUTVOLTAGE) != 1)
|
||||
DBG_8195A("Get Chip ID Failed\r");
|
||||
return ChipId;
|
||||
}
|
||||
|
||||
/*
|
||||
* 16 bytes FIFO ... 16*11/38400 = 0.004583 sec
|
||||
* (0.005/5)*166666666 = 166666.666 Tcpu
|
||||
*/
|
||||
static void INFRA_START_SECTION loguart_wait_tx_fifo_empty(void) {
|
||||
if (HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) & BIT_SOC_LOG_UART_EN) {
|
||||
int x = 16384;
|
||||
while ((!(HAL_READ8(LOG_UART_REG_BASE, 0x14) & BIT6)) && x--)
|
||||
; // иначе глючит LogUART, если переключение CLK приходится на вывод символов !
|
||||
}
|
||||
}
|
||||
|
||||
extern SPIC_INIT_PARA SpicInitParaAllClk[SpicMaxMode][CPU_CLK_TYPE_NO]; // 100021ec [144=0x90]
|
||||
static uint32 InitTabParaAllClk[3 * CPU_CLK_TYPE_NO] = {
|
||||
0x01310102, // BaudRate = 2, RdDummyCyle = 2, DelayLine = 63, SIO
|
||||
0x03310101, // 0201 - 40t, 0101 - 39t, 0102 - 72t, 0103 - 104t
|
||||
0x05310001, // 39t
|
||||
0x07310001,
|
||||
0x09310001,
|
||||
0x0B310001,
|
||||
|
||||
0x11311301, // BaudRate = 1, RdDummyCyle = 19, DelayLine = 63, DIO
|
||||
0x13311201, // 1201 - 36t
|
||||
0x15311101, // 1101 - 35t
|
||||
0x17311101,
|
||||
0x19311101,
|
||||
0x1B311101,
|
||||
|
||||
0x21311301, // BaudRate = 1, RdDummyCyle = 19, DelayLine = 63, DIO
|
||||
0x23311201, // 1201 - 36t
|
||||
0x25311101, // 1101 - 35t
|
||||
0x27311101,
|
||||
0x29311101,
|
||||
0x2B311101,
|
||||
};
|
||||
|
||||
struct spic_table_flash_type {
|
||||
uint8 cmd[12];
|
||||
uint8 strlr2;
|
||||
uint8 fbaud;
|
||||
uint8 addrlen;
|
||||
uint8 fsize;
|
||||
uint32 contrl;
|
||||
uint16 validcmd[3];
|
||||
uint8 manufacturerid;
|
||||
uint8 memorytype;
|
||||
};
|
||||
|
||||
//PSPIC_INIT_PARA pSpicInitPara;
|
||||
|
||||
struct spic_table_flash_type spic_table_flash = {
|
||||
{ // for FLASH MX25L8006E/1606E
|
||||
FLASH_CMD_FREAD, // REG_SPIC_READ_FAST_SINGLE 0x400060E0 0x0B
|
||||
FLASH_CMD_DREAD, // REG_SPIC_READ_DUAL_DATA 0x400060E4 0x3B
|
||||
FLASH_CMD_DREAD, // REG_SPIC_READ_DUAL_ADDR_DATA 0x400060E8 0x3B ?
|
||||
FLASH_CMD_QREAD, // REG_SPIC_READ_QUAD_DATA 0x400060EC 0x6B
|
||||
FLASH_CMD_4READ, // REG_SPIC_READ_QUAD_ADDR_DATA 0x400060F0 0xEB ?
|
||||
FLASH_CMD_PP, // REG_SPIC_WRITE_SIGNLE 0x400060F4 0x02
|
||||
FLASH_CMD_DPP, // REG_SPIC_WRITE_DUAL_DATA 0x400060F8 0xA2
|
||||
FLASH_CMD_DPP, // REG_SPIC_WRITE_DUAL_ADDR_DATA 0x400060FC 0xA2 ?
|
||||
FLASH_CMD_QPP, // REG_SPIC_WRITE_QUAD_DATA 0x40006100 0x32
|
||||
FLASH_CMD_4PP, // REG_SPIC_WRITE_QUAD_ADDR_DATA 0x40006104 0x38
|
||||
FLASH_CMD_WREN, // REG_SPIC_WRITE_ENABLE 0x40006108 0x06
|
||||
FLASH_CMD_RDSR // REG_SPIC_READ_STATUS 0x4000610C 0x05
|
||||
},
|
||||
BIT_FIFO_ENTRY(5) | BIT_SO_DUM, // REG_SPIC_CTRLR2 0x40006110 0x51
|
||||
BIT_FSCKDV(1), // REG_SPIC_FBAUDR 0x40006114 0x01
|
||||
BIT_ADDR_PHASE_LENGTH(3), // REG_SPIC_ADDR_LENGTH 0x40006118 0x03
|
||||
BIT_FLASE_SIZE(0x0F), // REG_SPIC_FLASE_SIZE 0x40006124 0x0E ?
|
||||
BIT_CS_H_WR_DUM_LEN(2)| BIT_AUTO_ADDR__LENGTH(3) | BIT_RD_DUMMY_LENGTH(0x0), // REG_SPIC_AUTO_LENGTH 0x4000611C 0x20030001 ?
|
||||
{
|
||||
BIT_WR_BLOCKING, // REG_SPIC_VALID_CMD 0x40006120 0x200 SpicOneBitMode
|
||||
BIT_WR_BLOCKING | BIT_RD_DUAL_I, // REG_SPIC_VALID_CMD 0x40006120 0x200 SpicOneBitMode
|
||||
BIT_WR_BLOCKING | BIT_RD_QUAD_O, // REG_SPIC_VALID_CMD 0x40006120 0x200 SpicOneBitMode
|
||||
},
|
||||
0xC2, 0x20 // MX25L8006/MX25L1606
|
||||
};
|
||||
|
||||
static void BOOT_RAM_TEXT_SECTION InitSpicBdRDCDL(PSPIC_INIT_PARA pspic) {
|
||||
// Disable SPI_FLASH User Mode
|
||||
// HAL_SPI_WRITE32(REG_SPIC_SSIENR, 0);
|
||||
DBG_8195A("%p = %p, %p\n", 0x40006000+REG_SPIC_AUTO_LENGTH, HAL_SPI_READ32(REG_SPIC_BAUDR), pspic->RdDummyCyle);
|
||||
HAL_SPI_WRITE32(REG_SPIC_AUTO_LENGTH, (HAL_SPI_READ32(REG_SPIC_AUTO_LENGTH) & 0xFFFF0000) | pspic->RdDummyCyle);
|
||||
// DBG_8195A("%p = %p, %p\n", 0x40006000+REG_SPIC_SER, HAL_SPI_READ32(REG_SPIC_SER), BIT_SER);
|
||||
// HAL_SPI_WRITE32(REG_SPIC_SER, BIT_SER);
|
||||
|
||||
FLASH_DDL_FCTRL(pspic->DelayLine); // SPI_DLY_CTRL_ADDR [7:0]
|
||||
|
||||
// DBG_8195A("%p = %p, %p\n", 0x40006000 + REG_SPIC_CTRLR1, HAL_SPI_READ32(REG_SPIC_CTRLR1), BIT_NDF(4));
|
||||
// HAL_SPI_WRITE32(REG_SPIC_CTRLR1, BIT_NDF(4));
|
||||
|
||||
|
||||
uint32 regval = HAL_SPI_READ32(REG_SPIC_CTRLR0)
|
||||
& (~(BIT_CMD_CH(3) | BIT_DATA_CH(3) | BIT_ADDR_CH(3)));
|
||||
|
||||
if(pspic->Mode.BitMode == SpicDualBitMode) {
|
||||
regval |= BIT_ADDR_CH(1) | BIT_DATA_CH(1);
|
||||
}
|
||||
else if(pspic->Mode.BitMode == SpicQuadBitMode) {
|
||||
regval |= BIT_ADDR_CH(2) | BIT_DATA_CH(2);
|
||||
}
|
||||
DBG_8195A("%p = %p, %p\n", 0x40006000+REG_SPIC_CTRLR0, HAL_SPI_READ32(REG_SPIC_CTRLR0), regval);
|
||||
HAL_SPI_WRITE32(REG_SPIC_CTRLR0, regval);
|
||||
|
||||
|
||||
DBG_8195A("%p = %p, %p\n", 0x40006000+REG_SPIC_VALID_CMD, HAL_SPI_READ32(REG_SPIC_VALID_CMD), spic_table_flash.validcmd[pspic->Mode.BitMode]);
|
||||
HAL_SPI_WRITE32(REG_SPIC_VALID_CMD, spic_table_flash.validcmd[pspic->Mode.BitMode]);
|
||||
|
||||
DBG_8195A("%p = %p, %p\n", 0x40006000+REG_SPIC_BAUDR, HAL_SPI_READ32(REG_SPIC_BAUDR), pspic->BaudRate);
|
||||
HAL_SPI_WRITE32(REG_SPIC_BAUDR, pspic->BaudRate); // & 0x00000FFF));
|
||||
|
||||
// Enable SPI_FLASH User Mode
|
||||
// HAL_SPI_WRITE32(REG_SPIC_SSIENR, BIT_SPIC_EN);
|
||||
// SpicWaitWipDoneRtl8195A(SpicInitParaAllClk[1][0]);
|
||||
}
|
||||
|
||||
void BOOT_RAM_TEXT_SECTION InitSpicFlashType(struct spic_table_flash_type *ptable_flash) {
|
||||
uint8_t * ptrb = &ptable_flash->cmd;
|
||||
volatile uint32_t * ptrreg = (volatile uint32_t *)(SPI_FLASH_CTRL_BASE + REG_SPIC_READ_FAST_SINGLE);// 0x400060E0
|
||||
do {
|
||||
DBG_8195A("%p = %p, %p\n", ptrreg, *ptrreg, *ptrb);
|
||||
*ptrreg++ = *ptrb++;
|
||||
} while(ptrb < (uint8_t *)(&ptable_flash->fsize));
|
||||
DBG_8195A("%p = %p, %p\n", ptrreg, *ptrreg, ptable_flash->contrl);
|
||||
ptrreg[0] = ptable_flash->contrl;
|
||||
DBG_8195A("%p = %p, %p\n", &ptrreg[1], ptrreg[1], ptable_flash->validcmd[SpicOneBitMode]);
|
||||
ptrreg[1] = ptable_flash->validcmd[SpicOneBitMode];
|
||||
DBG_8195A("%p = %p, %p\n", &ptrreg[2], ptrreg[2], ptable_flash->fsize);
|
||||
ptrreg[2] = ptable_flash->fsize;
|
||||
}
|
||||
|
||||
static int BOOT_RAM_TEXT_SECTION InitSpic(uint8 SpicBitMode) {
|
||||
#if 0
|
||||
// *(uint32 *)(&SpicInitParaAllClk[0][0].BaudRate) = 0x1311301; // patch
|
||||
SpicInitRtl8195AV02(CPU_CLK_TYPE_NO - 1 - ((HAL_SYS_CTRL_READ32(REG_SYS_CLK_CTRL1) >> 4) & 7),
|
||||
SpicDualBitMode);
|
||||
#else
|
||||
// SpicInitRtl8195AV02(1, SpicDualBitMode); // SpicOneBitMode); // 5-168, 4-136, 3-104, 2-72, 1-
|
||||
// InitSpicBdRDCDL(&SpicInitParaAllClk[1][0]);
|
||||
// SpicLoadInitParaFromClockRtl8195A(0, 1, &SpicInitParaAllClk[1][0]);
|
||||
#endif
|
||||
|
||||
_memset(SpicInitParaAllClk, 0, sizeof(SpicInitParaAllClk));
|
||||
uint32 * ptr = InitTabParaAllClk;
|
||||
uint8 x;
|
||||
for(x = 0; x < SpicMaxMode; x++) {
|
||||
*(uint32 *)&SpicInitParaAllClk[SpicOneBitMode][x].BaudRate = ptr[0];
|
||||
*(uint32 *)&SpicInitParaAllClk[SpicDualBitMode][x].BaudRate = ptr[CPU_CLK_TYPE_NO];
|
||||
*(uint32 *)&SpicInitParaAllClk[SpicQuadBitMode][x].BaudRate = ptr[CPU_CLK_TYPE_NO + CPU_CLK_TYPE_NO];
|
||||
ptr++;
|
||||
}
|
||||
ACTCK_FLASH_CCTRL(1);
|
||||
SLPCK_FLASH_CCTRL(1);
|
||||
// Disable SPI_FLASH User Mode
|
||||
HAL_SPI_WRITE32(REG_SPIC_SSIENR, 0);
|
||||
HalPinCtrlRtl8195A(SPI_FLASH, 0, 1);
|
||||
InitSpicFlashType(&spic_table_flash);
|
||||
InitSpicBdRDCDL(&SpicInitParaAllClk[SpicBitMode][((HAL_SYS_CTRL_READ32(REG_SYS_CLK_CTRL1) >> 4) & 7)]);
|
||||
#if 0 // 72
|
||||
HAL_SPI_WRITE32(REG_SPIC_AUTO_LENGTH, 0x20030002);
|
||||
HAL_SPI_WRITE32(REG_SPIC_BAUDR, 2);
|
||||
HAL_SPI_WRITE32(REG_SPIC_VALID_CMD, BIT_WR_BLOCKING);
|
||||
#else // 36
|
||||
// HAL_SPI_WRITE32(REG_SPIC_AUTO_LENGTH, 0x20030013);
|
||||
// HAL_SPI_WRITE32(REG_SPIC_BAUDR, 1);
|
||||
// HAL_SPI_WRITE32(REG_SPIC_VALID_CMD, BIT_WR_BLOCKING | BIT_RD_DUAL_I);
|
||||
#endif
|
||||
HAL_SPI_WRITE32(REG_SPIC_SER, BIT_SER);
|
||||
SPI_FLASH_PIN_FCTRL(ON);
|
||||
|
||||
// Enable SPI_FLASH User Mode
|
||||
HAL_SPI_WRITE32(REG_SPIC_SSIENR, BIT_SPIC_EN);
|
||||
|
||||
|
||||
// if(!SpicCmpDataForCalibrationRtl8195A()) {
|
||||
for(int i = 1; i < 4; i++) {
|
||||
for(int x = 0; x < 63; x++) {
|
||||
// Disable SPI_FLASH User Mode
|
||||
HAL_SPI_WRITE32(REG_SPIC_SSIENR, 0);
|
||||
HAL_SPI_WRITE32(REG_SPIC_AUTO_LENGTH, 0x20030000 + x);
|
||||
HAL_SPI_WRITE32(REG_SPIC_BAUDR, i);
|
||||
// Enable SPI_FLASH User Mode
|
||||
HAL_SPI_WRITE32(REG_SPIC_SSIENR, BIT_SPIC_EN);
|
||||
FLASH_DDL_FCTRL(49); // SPI_DLY_CTRL_ADDR [7:0]
|
||||
// HAL_SPI_WRITE32(REG_SPIC_FLUSH_FIFO, 1);
|
||||
if(SpicCmpDataForCalibrationRtl8195A()) {
|
||||
DiagPrintf("Spic init %d:%d:49\n", i, x);
|
||||
return 1;
|
||||
};
|
||||
};
|
||||
};
|
||||
return 0;
|
||||
// };
|
||||
// return 1;
|
||||
}
|
||||
|
||||
|
||||
/* SYSPlatformInit */
|
||||
static void INFRA_START_SECTION SYSPlatformInit(void) {
|
||||
__asm__ __volatile__ ("cpsid f\n");
|
||||
JtagOn();
|
||||
SetDebugFlgs();
|
||||
//----- SYS Init
|
||||
HAL_SYS_CTRL_WRITE32(REG_SYS_EFUSE_SYSCFG0,
|
||||
(HAL_SYS_CTRL_READ32(REG_SYS_EFUSE_SYSCFG0) & (~(BIT_MASK_SYS_EEROM_LDO_PAR_07_04 << BIT_SHIFT_SYS_EEROM_LDO_PAR_07_04))) | BIT_SYS_EEROM_LDO_PAR_07_04(6)); // & 0xF0FFFFFF | 0x6000000
|
||||
HAL_SYS_CTRL_WRITE32(REG_SYS_XTAL_CTRL1,
|
||||
(HAL_SYS_CTRL_READ32(REG_SYS_XTAL_CTRL1) & (~(BIT_MASK_SYS_XTAL_DRV_RF1 << BIT_SHIFT_SYS_XTAL_DRV_RF1))) | BIT_SYS_XTAL_DRV_RF1(1)); // & 0xFFFFFFE7 | 8;
|
||||
//----- SDIO_Device_Off
|
||||
HAL_PERI_ON_WRITE32(REG_PESOC_HCI_CLK_CTRL0,
|
||||
HAL_PERI_ON_READ32(REG_PESOC_HCI_CLK_CTRL0) & (~BIT_SOC_ACTCK_SDIO_DEV_EN));
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_HCI_COM_FUNC_EN,
|
||||
HAL_PERI_ON_READ32(REG_SOC_HCI_COM_FUNC_EN) & (~(BIT_SOC_HCI_SDIOD_ON_EN | BIT_SOC_HCI_SDIOD_OFF_EN)));
|
||||
HAL_PERI_ON_WRITE32(REG_HCI_PINMUX_CTRL,
|
||||
HAL_PERI_ON_READ32(REG_HCI_PINMUX_CTRL) & (~(BIT_HCI_SDIOD_PIN_EN)));
|
||||
//----- GPIO Adapter
|
||||
extern HAL_GPIO_ADAPTER gBoot_Gpio_Adapter;
|
||||
_memset(&gBoot_Gpio_Adapter, 0, sizeof(gBoot_Gpio_Adapter));
|
||||
_pHAL_Gpio_Adapter = &gBoot_Gpio_Adapter;
|
||||
#ifdef DEFAULT_BOOT_CLK_CPU
|
||||
//----- CLK CPU
|
||||
loguart_wait_tx_fifo_empty(); // иначе глючит LogUART, если переключение CLK приходится на вывод символов !
|
||||
#if DEFAULT_BOOT_CPU_CLOCK_SEL_DIV5_3
|
||||
// 6 - 200000000 Hz, 7 - 10000000 Hz, 8 - 50000000 Hz, 9 - 25000000 Hz, 10 - 12500000 Hz, 11 - 4000000 Hz
|
||||
HalCpuClkConfig(DEFAULT_BOOT_CPU_CLOCK_SEL_VALUE);
|
||||
*((int *)(SYSTEM_CTRL_BASE+REG_SYS_SYSPLL_CTRL1)) |= (1<<17);// REG_SYS_SYSPLL_CTRL1 |= BIT_SYS_SYSPLL_DIV5_3
|
||||
#else
|
||||
// 0 - 166666666 Hz, 1 - 83333333 Hz, 2 - 41666666 Hz, 3 - 20833333 Hz, 4 - 10416666 Hz, 5 - 4000000 Hz
|
||||
*((int *) (SYSTEM_CTRL_BASE + REG_SYS_SYSPLL_CTRL1)) &= ~(1 << 17); // REG_SYS_SYSPLL_CTRL1 &= ~BIT_SYS_SYSPLL_DIV5_3
|
||||
HalCpuClkConfig(DEFAULT_BOOT_CPU_CLOCK_SEL_VALUE);
|
||||
#endif // CPU_CLOCK_SEL_DIV5_3
|
||||
#endif // DEFAULT_CLK_CPU
|
||||
//----- System
|
||||
VectorTableInitRtl8195A(STACK_TOP); // 0x1FFFFFFC
|
||||
HalInitPlatformLogUartV02(); // Show "<RTL8195A>"... :(
|
||||
HalInitPlatformTimerV02();
|
||||
__asm__ __volatile__ ("cpsie f\n");
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------
|
||||
Копирует данные из области align(4) (flash, registers, ...) в область align(1) (ram)
|
||||
--------------------------------------------------------------------------------------*/
|
||||
static unsigned int BOOT_RAM_TEXT_SECTION flashcpy(unsigned int faddr,
|
||||
void *dist, unsigned int size) {
|
||||
union {
|
||||
unsigned char uc[4];
|
||||
unsigned int ud;
|
||||
} tmp;
|
||||
if (faddr < SPI_FLASH_BASE)
|
||||
faddr += SPI_FLASH_BASE;
|
||||
unsigned char * pd = (unsigned char *) dist;
|
||||
unsigned int *p = (unsigned int *) ((unsigned int) faddr & (~3));
|
||||
unsigned int xlen = (unsigned int) faddr & 3;
|
||||
unsigned int len = size;
|
||||
|
||||
if (xlen) {
|
||||
tmp.ud = *p++;
|
||||
while (len) {
|
||||
len--;
|
||||
*pd++ = tmp.uc[xlen++];
|
||||
if (xlen & 4)
|
||||
break;
|
||||
};
|
||||
};
|
||||
xlen = len >> 2;
|
||||
while (xlen) {
|
||||
tmp.ud = *p++;
|
||||
*pd++ = tmp.uc[0];
|
||||
*pd++ = tmp.uc[1];
|
||||
*pd++ = tmp.uc[2];
|
||||
*pd++ = tmp.uc[3];
|
||||
xlen--;
|
||||
};
|
||||
if (len & 3) {
|
||||
tmp.ud = *p;
|
||||
pd[0] = tmp.uc[0];
|
||||
if (len & 2) {
|
||||
pd[1] = tmp.uc[1];
|
||||
if (len & 1) {
|
||||
pd[2] = tmp.uc[2];
|
||||
};
|
||||
};
|
||||
};
|
||||
return size;
|
||||
}
|
||||
|
||||
enum {
|
||||
SEG_ID_ERR,
|
||||
SEG_ID_SRAM,
|
||||
SEG_ID_TCM,
|
||||
SEG_ID_SDRAM,
|
||||
SEG_ID_SOC,
|
||||
SEG_ID_FLASH,
|
||||
SEG_ID_CPU,
|
||||
SEG_ID_ROM,
|
||||
SEG_ID_MAX
|
||||
} SEG_ID;
|
||||
|
||||
static const char * const txt_tab_seg[] = {
|
||||
"UNK", // 0
|
||||
"SRAM", // 1
|
||||
"TCM", // 2
|
||||
"SDRAM", // 3
|
||||
"SOC", // 4
|
||||
"FLASH", // 5
|
||||
"CPU", // 6
|
||||
"ROM" // 7
|
||||
};
|
||||
|
||||
static const uint32 tab_seg_def[] = { 0x10000000, 0x10070000, 0x1fff0000,
|
||||
0x20000000, 0x30000000, 0x30200000, 0x40000000, 0x40800000, 0x98000000,
|
||||
0xA0000000, 0xE0000000, 0xE0010000, 0x00000000, 0x00050000 };
|
||||
|
||||
static uint32 BOOT_RAM_TEXT_SECTION get_seg_id(uint32 addr, int32 size) {
|
||||
uint32 ret = SEG_ID_ERR;
|
||||
uint32 * ptr = &tab_seg_def;
|
||||
if (size > 0) {
|
||||
do {
|
||||
ret++;
|
||||
if (addr >= ptr[0] && addr + size <= ptr[1]) {
|
||||
return ret;
|
||||
};
|
||||
ptr += 2;
|
||||
} while (ret < SEG_ID_MAX);
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint32 BOOT_RAM_TEXT_SECTION load_img2_head(uint32 faddr, PIMG2HEAD hdr) {
|
||||
flashcpy(faddr, hdr, sizeof(IMG2HEAD));
|
||||
uint32 ret = get_seg_id(hdr->seg.ldaddr, hdr->seg.size);
|
||||
if (hdr->sign[1] == IMG_SIGN2_RUN) {
|
||||
if (hdr->sign[0] == IMG_SIGN1_RUN) {
|
||||
ret |= 1 << 9;
|
||||
} else if (hdr->sign[0] == IMG_SIGN1_SWP) {
|
||||
ret |= 1 << 8;
|
||||
};
|
||||
}
|
||||
if (*(uint32_t *) (&hdr->rtkwin) == IMG2_SIGN_DW1_TXT) {
|
||||
ret |= 1 << 10;
|
||||
};
|
||||
return ret;
|
||||
}
|
||||
|
||||
static uint32 BOOT_RAM_TEXT_SECTION load_segs(uint32 faddr, PIMG2HEAD hdr,
|
||||
uint8 flgload) {
|
||||
uint32 fnextaddr = faddr;
|
||||
uint8 segnum = 0;
|
||||
while (1) {
|
||||
uint32 seg_id = get_seg_id(hdr->seg.ldaddr, hdr->seg.size);
|
||||
if (flgload
|
||||
&& (seg_id == SEG_ID_SRAM || seg_id == SEG_ID_TCM
|
||||
|| seg_id == SEG_ID_SDRAM)) {
|
||||
#if CONFIG_DEBUG_LOG > 1
|
||||
DBG_8195A("Load Flash seg%d: 0x%08x -> %s: 0x%08x, size: %d\n",
|
||||
segnum, faddr, txt_tab_seg[seg_id], hdr->seg.ldaddr,
|
||||
hdr->seg.size);
|
||||
#endif
|
||||
fnextaddr += flashcpy(fnextaddr, hdr->seg.ldaddr, hdr->seg.size);
|
||||
} else if (seg_id) {
|
||||
#if CONFIG_DEBUG_LOG > 2
|
||||
DBG_8195A("Skip Flash seg%d: 0x%08x -> %s: 0x%08x, size: %d\n", segnum,
|
||||
faddr, txt_tab_seg[seg_id], hdr->seg.ldaddr, hdr->seg.size);
|
||||
#endif
|
||||
fnextaddr += hdr->seg.size;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
fnextaddr += flashcpy(fnextaddr, &hdr->seg, sizeof(IMGSEGHEAD));
|
||||
segnum++;
|
||||
}
|
||||
return fnextaddr;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------
|
||||
* 0 - default image (config data + 0), 1 - image N1, 2 - image N2, ...
|
||||
--------------------------------------------------------------------------------------*/
|
||||
static int BOOT_RAM_TEXT_SECTION loadUserImges(int imgnum) {
|
||||
IMG2HEAD hdr;
|
||||
int imagenum = 1;
|
||||
uint32 faddr = 0xb000; // start image2 in flash
|
||||
DBG_8195A("Selected Image %d.\n", imgnum);
|
||||
|
||||
while (1) {
|
||||
faddr = (faddr + FLASH_SECTOR_SIZE - 1) & (~(FLASH_SECTOR_SIZE - 1));
|
||||
uint32 img_id = load_img2_head(faddr, &hdr);
|
||||
if ((img_id >> 8) > 4 || (uint8) img_id != 0) {
|
||||
faddr = load_segs(faddr + 0x10, &hdr.seg, imagenum == imgnum);
|
||||
if (imagenum == imgnum) {
|
||||
// DBG_8195A("Image%d: %s\n", imgnum, hdr.name);
|
||||
break;
|
||||
}
|
||||
imagenum++;
|
||||
} else if (imagenum) {
|
||||
DBG_8195A("No Image%d! Trying Image0...\n", imgnum);
|
||||
// пробуем загрузить image по умолчанию, по записи в секторе установок
|
||||
flashcpy(FLASH_SYSTEM_DATA_ADDR, &faddr, sizeof(faddr));
|
||||
if (faddr < 0x8000000)
|
||||
faddr += SPI_FLASH_BASE;
|
||||
if (get_seg_id(faddr, 0x100) == SEG_ID_FLASH) {
|
||||
imagenum = 0;
|
||||
imgnum = 0;
|
||||
} else {
|
||||
DBG_8195A("No Image0!\n");
|
||||
imagenum = -1;
|
||||
break;
|
||||
};
|
||||
} else {
|
||||
imagenum = -1;
|
||||
break;
|
||||
}
|
||||
};
|
||||
return imagenum;
|
||||
}
|
||||
|
||||
//----- IsForceLoadDefaultImg2
|
||||
static uint8 BOOT_RAM_TEXT_SECTION IsForceLoadDefaultImg2(void) {
|
||||
uint8 gpio_pin[4];
|
||||
HAL_GPIO_PIN GPIO_Pin;
|
||||
HAL_GPIO_PIN_STATE flg;
|
||||
int result = 0;
|
||||
flashcpy(FLASH_SYSTEM_DATA_ADDR + 0x08, &gpio_pin, sizeof(gpio_pin)); // config data + 8
|
||||
// _pHAL_Gpio_Adapter = &gBoot_Gpio_Adapter;
|
||||
for (int i = 1; i; i--) {
|
||||
uint8 x = gpio_pin[i];
|
||||
result <<= 1;
|
||||
if (x != 0xff) {
|
||||
GPIO_Pin.pin_name = HAL_GPIO_GetIPPinName_8195a(x & 0x7F);
|
||||
if (x & 0x80) {
|
||||
GPIO_Pin.pin_mode = DIN_PULL_LOW;
|
||||
flg = GPIO_PIN_HIGH;
|
||||
} else {
|
||||
GPIO_Pin.pin_mode = DIN_PULL_HIGH;
|
||||
flg = GPIO_PIN_LOW;
|
||||
}
|
||||
HAL_GPIO_Init_8195a(&GPIO_Pin);
|
||||
if (HAL_GPIO_ReadPin_8195a(&GPIO_Pin) == flg) {
|
||||
result |= 1;
|
||||
}
|
||||
HAL_GPIO_DeInit_8195a(&GPIO_Pin);
|
||||
}
|
||||
}
|
||||
// _pHAL_Gpio_Adapter->IrqHandle.IrqFun = NULL;
|
||||
return result;
|
||||
}
|
||||
/* RTL Console ROM */
|
||||
static void BOOT_RAM_TEXT_SECTION RtlConsolRam(void) {
|
||||
// DiagPrintf("\r\nRTL Console ROM\r\n");
|
||||
// RtlConsolInit(ROM_STAGE, (uint32_t) 6, (void*) &UartLogRomCmdTable);
|
||||
pUartLogCtl->RevdNo = UART_LOG_HISTORY_LEN;
|
||||
pUartLogCtl->BootRdy = 1;
|
||||
pUartLogCtl->pTmpLogBuf->UARTLogBuf[0] = '?';
|
||||
pUartLogCtl->pTmpLogBuf->BufCount = 1;
|
||||
pUartLogCtl->ExecuteCmd = 1;
|
||||
RtlConsolTaskRom(pUartLogCtl);
|
||||
}
|
||||
|
||||
/* Enter Image 1.5 */
|
||||
static void BOOT_RAM_TEXT_SECTION EnterImage15(int flg) {
|
||||
|
||||
if (flg)
|
||||
_memset(&__rom_bss_start__, 0, &__rom_bss_end__ - &__rom_bss_start__);
|
||||
|
||||
SYSPlatformInit();
|
||||
|
||||
if (!flg)
|
||||
DBG_8195A("\r===== Enter FLASH-Boot ====\n");
|
||||
else
|
||||
DBG_8195A("\r===== Enter SRAM-Boot %d ====\n", flg);
|
||||
|
||||
#if CONFIG_DEBUG_LOG > 1
|
||||
DBG_8195A("CPU CLK: %d Hz, SOC FUNC EN: %p\r\n", HalGetCpuClk(),
|
||||
HAL_PERI_ON_READ32(REG_SOC_FUNC_EN));
|
||||
#endif
|
||||
uint8 ChipId = _Get_ChipId();
|
||||
if (ChipId < CHIP_ID_8195AM) {
|
||||
//----- SDRAM Off
|
||||
SDR_PIN_FCTRL(OFF);
|
||||
LDO25M_CTRL(OFF);
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN, HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) | BIT(21)); // Flag SDRAM Off
|
||||
} else {
|
||||
//----- SDRAM On
|
||||
LDO25M_CTRL(ON);
|
||||
HAL_SYS_CTRL_WRITE32(REG_SYS_REGU_CTRL0,
|
||||
(HAL_SYS_CTRL_READ32(REG_SYS_REGU_CTRL0) & 0xfffff) | BIT_SYS_REGU_LDO25M_ADJ(0x0e));
|
||||
SDR_PIN_FCTRL(ON);
|
||||
};
|
||||
InitSpic(SpicDualBitMode); // SpicOneBitMode)
|
||||
if (!SpicCmpDataForCalibrationRtl8195A()) {
|
||||
DBG_8195A("Error Init Spic DIO!\n");
|
||||
RtlConsolRam();
|
||||
}
|
||||
if ((HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) & BIT(21)) == 0) { // уже загружена?
|
||||
// extern DRAM_DEVICE_INFO SdrDramInfo_rom; // 50 MHz
|
||||
if (!SdrControllerInit_rom(&SdrDramInfo)) { // 100 MHz
|
||||
DBG_8195A("SDR Controller Init fail!\n");
|
||||
RtlConsolRam();
|
||||
}
|
||||
#if 0 // Test SDRAM
|
||||
else {
|
||||
uint32 *ptr = SDR_SDRAM_BASE;
|
||||
uint32 tt = 0x55AA55AA;
|
||||
for (int i = 0; i < 512 * 1024; i++) {
|
||||
ptr[i] = tt++;
|
||||
};
|
||||
tt = 0x55AA55AA;
|
||||
for (int i = 0; i < 512 * 1024; i++) {
|
||||
if (ptr[i] != tt) {
|
||||
DBG_8195A("SDR err %p %p != %p!\n", &ptr[i], ptr[i], tt);
|
||||
RtlConsolRam();
|
||||
}
|
||||
tt++;
|
||||
};
|
||||
DBG_8195A("SDR tst end\n");
|
||||
};
|
||||
#endif // test
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN, HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) | BIT(21));
|
||||
};
|
||||
if (!flg)
|
||||
loadUserImges(IsForceLoadDefaultImg2() + 1);
|
||||
if (_strcmp((const char *) &__image2_validate_code__, IMG2_SIGN_TXT)) {
|
||||
DBG_MISC_ERR("Invalid Image Signature!\n");
|
||||
RtlConsolRam();
|
||||
}
|
||||
DBG_8195A("Img Sign: %s, Go @ 0x%08x\r\n", &__image2_validate_code__,
|
||||
__image2_entry_func__);
|
||||
__image2_entry_func__();
|
||||
}
|
||||
|
||||
/* RtlBootToSram */
|
||||
static void BOOT_RAM_TEXT_SECTION RtlBoot1ToSram(void) {
|
||||
EnterImage15(1);
|
||||
}
|
||||
/* RtlBootToSram */
|
||||
static void BOOT_RAM_TEXT_SECTION RtlBoot2ToSram(void) {
|
||||
EnterImage15(2);
|
||||
}
|
||||
/* RtlBootToSram */
|
||||
static void BOOT_RAM_TEXT_SECTION RtlBoot3ToSram(void) {
|
||||
EnterImage15(3);
|
||||
}
|
||||
/* RtlBootToSram */
|
||||
static void BOOT_RAM_TEXT_SECTION RtlBoot4ToSram(void) {
|
||||
EnterImage15(4);
|
||||
}
|
||||
|
||||
static void BOOT_RAM_TEXT_SECTION RtlBootToFlash(void) {
|
||||
EnterImage15(0);
|
||||
}
|
||||
|
|
@ -0,0 +1,279 @@
|
|||
/*
|
||||
* StartUp USDK v0.2 (19/10/2017)
|
||||
* Created on: 02/03/2017
|
||||
* Author: pvvx
|
||||
*/
|
||||
|
||||
#include "rtl8195a.h"
|
||||
#include "diag.h"
|
||||
#include "hal_spi_flash.h"
|
||||
#include "hal_api.h"
|
||||
#include "hal_platform.h"
|
||||
#include "diag.h"
|
||||
#include "hal_diag.h"
|
||||
#include "rtl8195a_uart.h"
|
||||
#include "rtl8195a/rtl8195a_peri_on.h"
|
||||
#include "hal_peri_on.h"
|
||||
#include "rtl_bios_data.h"
|
||||
#include "wifi_conf.h"
|
||||
#include "rtl_consol.h"
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
void InfraStart(void);
|
||||
//extern void HalWdgIntrHandle(void);
|
||||
extern void xPortPendSVHandler(void);
|
||||
extern void xPortSysTickHandler(void);
|
||||
extern void vPortSVCHandler(void);
|
||||
extern void rtl_libc_init(void);
|
||||
extern _LONG_CALL_ void HalCpuClkConfig(unsigned char CpuType);
|
||||
extern void PSHalInitPlatformLogUart(void);
|
||||
extern _LONG_CALL_ void UartLogCmdExecute(PUART_LOG_CTL pUartLogCtlExe);
|
||||
extern void HalReInitPlatformTimer(void);
|
||||
extern void SystemCoreClockUpdate (void);
|
||||
extern void En32KCalibration(void);
|
||||
extern void SdrCtrlInit(void);
|
||||
extern void InitSoCPM(void);
|
||||
extern uint32_t SdrControllerInit(void);
|
||||
//extern void ShowRamBuildInfo(void); // app_start.c: void ShowRamBuildInfo(void)
|
||||
//void HalNMIHandler_Patch(void);
|
||||
void SDIO_Device_Off(void);
|
||||
//void VectorTableOverrideRtl8195A(uint32_t StackP);
|
||||
void SYSPlatformInit(void);
|
||||
|
||||
#define FIX_SDR_CALIBRATION // for speed :)
|
||||
//-------------------------------------------------------------------------
|
||||
// Data declarations
|
||||
extern uint8_t __bss_start__, __bss_end__;
|
||||
extern const unsigned char cus_sig[32]; // images name
|
||||
//extern HAL_TIMER_OP HalTimerOp;
|
||||
|
||||
IMAGE2_START_RAM_FUN_SECTION RAM_START_FUNCTION gImage2EntryFun0 =
|
||||
{ InfraStart + 1 };
|
||||
#ifdef CONFIG_SDR_EN
|
||||
#ifdef FIX_SDR_CALIBRATION // for speed :)
|
||||
#include "rtl8195a/rtl8195a_sdr.h"
|
||||
static void sdr_init(void) {
|
||||
HAL_SYS_CTRL_WRITE32(REG_SYS_REGU_CTRL0,
|
||||
((HAL_SYS_CTRL_READ32(REG_SYS_REGU_CTRL0) & 0xfffff) | BIT_SYS_REGU_LDO25M_ADJ(0x03))); // ROM: BIT_SYS_REGU_LDO25M_ADJ(0x0e)? HAL RAM BIT_SYS_REGU_LDO25M_ADJ(0x03)
|
||||
LDO25M_CTRL(ON);
|
||||
SRAM_MUX_CFG(0x2);
|
||||
SDR_CLK_SEL(SDR_CLOCK_SEL_VALUE); // REG_PESOC_CLK_SEL
|
||||
HAL_PERI_ON_WRITE32(REG_GPIO_PULL_CTRL4, 0);
|
||||
ACTCK_SDR_CCTRL(ON);
|
||||
SLPCK_SDR_CCTRL(ON);
|
||||
HalPinCtrlRtl8195A(SDR, 0, ON); // SDR_PIN_FCTRL(ON);
|
||||
MEM_CTRL_FCTRL(ON);
|
||||
// HalDelayUs(1000);
|
||||
// read calibration data from system data FLASH_SDRC_PARA_BASE
|
||||
union { uint8_t b[8]; uint16_t s[4]; uint32_t l[2]; uint64_t d;} value;
|
||||
uint32_t faddr = SPI_FLASH_BASE + FLASH_SDRC_PARA_BASE + CPU_CLOCK_SEL_VALUE*8 + CPU_CLOCK_SEL_DIV5_3*8*8; // step 8 in FLASH_SDRC_PARA_BASE[64 + 64 bytes]
|
||||
value.d = *((volatile uint64_t *)faddr);
|
||||
if(value.s[0] == 0xFE01 && (value.b[4]^value.b[5]) == 0xFF && (value.b[6]^value.b[7]) == 0xFF) {
|
||||
DBG_8195A("SDR flash calibration [%08x]: %02x-%02x ", faddr, value.b[4], value.b[6]);
|
||||
} else {
|
||||
value.b[4] = 0; // TapCnt
|
||||
#if CONFIG_CPU_CLK < 6
|
||||
value.b[6] = 0x11; // RdPipe
|
||||
#elif CONFIG_CPU_CLK == 7
|
||||
value.b[6] = 0x23; // RdPipe
|
||||
#else
|
||||
value.b[6] = 0x19; // RdPipe
|
||||
#endif
|
||||
DBG_8195A("Use fix SDR calibration: %02x-%02x ", value.b[4], value.b[6]);
|
||||
}
|
||||
// set all_mode _idle
|
||||
HAL_SDR_WRITE32(REG_SDR_CSR, 0x700);
|
||||
// WRAP_MISC setting
|
||||
HAL_SDR_WRITE32(REG_SDR_MISC, 0x00000001);
|
||||
// PCTL setting
|
||||
HAL_SDR_WRITE32(REG_SDR_DCR, 0x00000008);
|
||||
HAL_SDR_WRITE32(REG_SDR_IOCR, (uint32_t)value.b[4] << PCTL_IOCR_RD_PIPE_BFO);
|
||||
HAL_SDR_WRITE32(REG_SDR_EMR2, 0x00000000);
|
||||
HAL_SDR_WRITE32(REG_SDR_EMR1, 0x00000006);
|
||||
HAL_SDR_WRITE32(REG_SDR_MR, 0x00000022);
|
||||
HAL_SDR_WRITE32(REG_SDR_DRR, 0x09030e07);
|
||||
HAL_SDR_WRITE32(REG_SDR_TPR0, 0x00002652);
|
||||
HAL_SDR_WRITE32(REG_SDR_TPR1, 0x00068873);
|
||||
HAL_SDR_WRITE32(REG_SDR_TPR2, 0x00000042);
|
||||
// start to init
|
||||
HAL_SDR_WRITE32(REG_SDR_CCR, 0x01);
|
||||
while ((HAL_SDR_READ32(REG_SDR_CCR) & 0x1) == 0x0)
|
||||
DBG_8195A(".");
|
||||
// enter mem_mode
|
||||
HAL_SDR_WRITE32(REG_SDR_CSR, 0x600);
|
||||
SDR_DDL_FCTRL((uint32_t)value.b[6]);
|
||||
DBG_8195A(" ok\n");
|
||||
}
|
||||
#endif // FIX_SDR_CALIBRATION
|
||||
#endif // CONFIG_SDR_EN
|
||||
/*
|
||||
//----- HalNMIHandler_Patch
|
||||
void HalNMIHandler_Patch(void) {
|
||||
DBG_8195A_HAL("%s:NMI Error!\n", __func__);
|
||||
if ( HAL_READ32(VENDOR_REG_BASE, 0) < 0)
|
||||
HalWdgIntrHandle(); // ROM: HalWdgIntrHandle = 0x3485;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* 16 bytes FIFO ... 16*11/38400 = 0.004583 sec
|
||||
* (0.005/5)*166666666 = 166666.666
|
||||
*/
|
||||
static void INFRA_START_SECTION loguart_wait_tx_fifo_empty(void) {
|
||||
int x = 16384;
|
||||
while((!(HAL_READ8(LOG_UART_REG_BASE, 0x14) & BIT6)) && x--);
|
||||
}
|
||||
|
||||
//----- SDIO_Device_Off
|
||||
void INFRA_START_SECTION SDIO_Device_Off(void) {
|
||||
HAL_PERI_ON_WRITE32(REG_PESOC_HCI_CLK_CTRL0,
|
||||
HAL_PERI_ON_READ32(REG_PESOC_HCI_CLK_CTRL0)
|
||||
& (~BIT_SOC_ACTCK_SDIO_DEV_EN));
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_HCI_COM_FUNC_EN,
|
||||
HAL_PERI_ON_READ32(REG_SOC_HCI_COM_FUNC_EN)
|
||||
& (~(BIT_SOC_HCI_SDIOD_ON_EN | BIT_SOC_HCI_SDIOD_OFF_EN)));
|
||||
HAL_PERI_ON_WRITE32(REG_HCI_PINMUX_CTRL,
|
||||
HAL_PERI_ON_READ32(REG_HCI_PINMUX_CTRL)
|
||||
& (~(BIT_HCI_SDIOD_PIN_EN)));
|
||||
}
|
||||
|
||||
//----- SYSPlatformInit
|
||||
void INFRA_START_SECTION SYSPlatformInit(void) {
|
||||
HAL_SYS_CTRL_WRITE32(REG_SYS_EFUSE_SYSCFG0,
|
||||
(HAL_SYS_CTRL_READ32(REG_SYS_EFUSE_SYSCFG0)
|
||||
& (~(BIT_MASK_SYS_EEROM_LDO_PAR_07_04 << BIT_SHIFT_SYS_EEROM_LDO_PAR_07_04)))
|
||||
| BIT_SYS_EEROM_LDO_PAR_07_04(6)); // & 0xF0FFFFFF | 0x6000000
|
||||
HAL_SYS_CTRL_WRITE32(REG_SYS_XTAL_CTRL1,
|
||||
(HAL_SYS_CTRL_READ32(REG_SYS_XTAL_CTRL1)
|
||||
& (~(BIT_MASK_SYS_XTAL_DRV_RF1 << BIT_SHIFT_SYS_XTAL_DRV_RF1)))
|
||||
| BIT_SYS_XTAL_DRV_RF1(1)); // & 0xFFFFFFE7 | 8;
|
||||
}
|
||||
|
||||
// weak __low_level_init function!
|
||||
__weak void __low_level_init(void) {
|
||||
}
|
||||
|
||||
// weak main function!
|
||||
__weak int main(void) {
|
||||
DiagPrintf("\r\nRTL Console ROM: Start - press key 'Up', Help '?'\r\n");
|
||||
while (pUartLogCtl->ExecuteEsc != 1);
|
||||
pUartLogCtl->RevdNo = 0;
|
||||
pUartLogCtl->BootRdy = 1;
|
||||
DiagPrintf("\r<RTL>");
|
||||
while (1) {
|
||||
while (pUartLogCtl->ExecuteCmd != 1);
|
||||
UartLogCmdExecute((PUART_LOG_CTL) pUartLogCtl);
|
||||
DiagPrintf("\r<RTL>");
|
||||
pUartLogCtl->ExecuteCmd = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----- InfraStart
|
||||
void INFRA_START_SECTION InfraStart(void) {
|
||||
// NewVectorTable[2] = HalNMIHandler_Patch;
|
||||
DBG_8195A("===== Enter Image: %s ====\n", cus_sig);
|
||||
// ShowRamBuildInfo(); // app_start.c: void ShowRamBuildInfo(void)
|
||||
memset(&__bss_start__, 0, &__bss_end__ - &__bss_start__);
|
||||
rtl_libc_init(); // ROM Lib C init (rtl_printf!)
|
||||
// SYSPlatformInit();
|
||||
// SDIO_Device_Off();
|
||||
//- Должно быть в boot
|
||||
extern HAL_GPIO_ADAPTER gBoot_Gpio_Adapter;
|
||||
memset(&gBoot_Gpio_Adapter, 0, sizeof(gBoot_Gpio_Adapter));
|
||||
_pHAL_Gpio_Adapter = &gBoot_Gpio_Adapter;
|
||||
VectorTableInitRtl8195A(STACK_TOP); // 0x1FFFFFFC
|
||||
loguart_wait_tx_fifo_empty(); // иначе глючит LogUART, если переключение CLK приходится на вывод символов !
|
||||
#if 1 // if set CLK CPU
|
||||
if(HalGetCpuClk() != PLATFORM_CLOCK) {
|
||||
//----- CLK CPU
|
||||
#if CPU_CLOCK_SEL_DIV5_3
|
||||
// 6 - 200000000 Hz, 7 - 10000000 Hz, 8 - 50000000 Hz, 9 - 25000000 Hz, 10 - 12500000 Hz, 11 - 4000000 Hz
|
||||
HalCpuClkConfig(CPU_CLOCK_SEL_VALUE);
|
||||
*((int *)(SYSTEM_CTRL_BASE+REG_SYS_SYSPLL_CTRL1)) |= (1<<17);// REG_SYS_SYSPLL_CTRL1 |= BIT_SYS_SYSPLL_DIV5_3
|
||||
#else
|
||||
// 0 - 166666666 Hz, 1 - 83333333 Hz, 2 - 41666666 Hz, 3 - 20833333 Hz, 4 - 10416666 Hz, 5 - 4000000 Hz
|
||||
*((int *) (SYSTEM_CTRL_BASE + REG_SYS_SYSPLL_CTRL1)) &= ~(1 << 17); // REG_SYS_SYSPLL_CTRL1 &= ~BIT_SYS_SYSPLL_DIV5_3
|
||||
HalCpuClkConfig(CPU_CLOCK_SEL_VALUE);
|
||||
#endif // CPU_CLOCK_SEL_DIV5_3
|
||||
};
|
||||
#endif
|
||||
PSHalInitPlatformLogUart(); // HalInitPlatformLogUartV02(); // Show "<RTL8195A>"... :(
|
||||
HalReInitPlatformTimer(); // HalInitPlatformTimerV02(); HalTimerOpInit_Patch((void*) (&HalTimerOp));
|
||||
SystemCoreClockUpdate();
|
||||
En32KCalibration();
|
||||
|
||||
//---- Spic
|
||||
// _memset(SpicInitParaAllClk, 0, sizeof(SpicInitParaAllClk));
|
||||
*(uint32 *)(&SpicInitParaAllClk[0][0].BaudRate) = 0x01310202; // patch
|
||||
*(uint32 *)(&SpicInitParaAllClk[1][0].BaudRate) = 0x11311301; // patch
|
||||
// *(uint32 *)(&SpicInitParaAllClk[2][0].BaudRate) = 0x21311301; // patch
|
||||
SPI_FLASH_PIN_FCTRL(ON);
|
||||
/*
|
||||
// uint8 SpicBaudRate = CPU_CLK_TYPE_NO - 1 - ((HAL_SYS_CTRL_READ32(REG_SYS_CLK_CTRL1) >> 4) & 7);
|
||||
uint8 SpicBaudRate = 3; // HAL_SYS_CTRL_READ32(REG_SYS_CLK_CTRL1) >> 4) & 7;
|
||||
DBG_8195A("SpicBaudRate = %d\n", SpicBaudRate);
|
||||
SpicInitRtl8195AV02(SpicBaudRate, SpicDualBitMode);
|
||||
if(!SpicCmpDataForCalibrationRtl8195A()) {
|
||||
DBG_8195A("ReInit Spic to SIO...\n");
|
||||
SpicInitRtl8195AV02(SpicBaudRate, SpicOneBitMode);
|
||||
if(!SpicCmpDataForCalibrationRtl8195A()) {
|
||||
DBG_8195A("Error Init Spic!\n");
|
||||
};
|
||||
};
|
||||
*/
|
||||
// SpicFlashInitRtl8195A(SpicDualBitMode); // SpicReadIDRtl8195A(); SpicDualBitMode
|
||||
#ifdef CONFIG_SDR_EN
|
||||
//---- SDRAM
|
||||
uint8 ChipId = HalGetChipId();
|
||||
if (ChipId >= CHIP_ID_8195AM) {
|
||||
if((HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) & BIT(21)) == 0) { // SDR not init?
|
||||
#ifdef FIX_SDR_CALIBRATION // for speed :)
|
||||
sdr_init();
|
||||
#else // not FIX_SDR_CALIBRATION
|
||||
SdrCtrlInit();
|
||||
if(!SdrControllerInit()) {
|
||||
DBG_8195A("SDR Controller Init fail!\n");
|
||||
};
|
||||
#endif // FIX_SDR_CALIBRATION
|
||||
};
|
||||
// clear SDRAM bss
|
||||
extern uint8 __sdram_bss_start__[];
|
||||
extern uint8 __sdram_bss_end__[];
|
||||
if((uint32)__sdram_bss_end__-(uint32)__sdram_bss_start__ > 0)
|
||||
memset(__sdram_bss_start__, 0, (uint32)__sdram_bss_end__-(uint32)__sdram_bss_start__);
|
||||
}
|
||||
else // if (ChipId < CHIP_ID_8195AM)
|
||||
{
|
||||
//----- SDRAM Off
|
||||
SDR_PIN_FCTRL(OFF);
|
||||
LDO25M_CTRL(OFF);
|
||||
};
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN, HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) | BIT(21)); // Flag SDRAM Init or None
|
||||
#else
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN, HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) & (~BIT(21))); // Flag SDRAM Not Init
|
||||
#endif // CONFIG_SDR_EN
|
||||
//----- Close Flash
|
||||
SPI_FLASH_PIN_FCTRL(OFF);
|
||||
|
||||
InitSoCPM();
|
||||
VectorTableInitForOSRtl8195A(&vPortSVCHandler, &xPortPendSVHandler,
|
||||
&xPortSysTickHandler);
|
||||
|
||||
#if CONFIG_DEBUG_LOG > 4
|
||||
DBG_8195A("\rSet CPU CLK: %d Hz, SOC FUNC EN: %p\r\n", HalGetCpuClk(), HAL_PERI_ON_READ32(REG_SOC_FUNC_EN));
|
||||
#endif
|
||||
|
||||
// force SP align to 8 byte not 4 byte (initial SP is 4 byte align)
|
||||
__asm(
|
||||
"mov r0, sp\n"
|
||||
"bic r0, r0, #7\n"
|
||||
"mov sp, r0\n"
|
||||
);
|
||||
|
||||
__low_level_init();
|
||||
|
||||
main();
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,827 @@
|
|||
/*
|
||||
* BootLoader
|
||||
* startup.o sdk-ameba-rtl8710af-v3.5a_without_NDA_GCC_V1.0.0
|
||||
* pvvx 2016
|
||||
*/
|
||||
|
||||
#include "rtl8195a.h"
|
||||
#include "diag.h"
|
||||
#include "hal_spi_flash.h"
|
||||
#include "hal_api.h"
|
||||
#include "hal_platform.h"
|
||||
#include "diag.h"
|
||||
#include "hal_diag.h"
|
||||
#include "rtl8195a_uart.h"
|
||||
#include "rtl8195a/rtl8195a_peri_on.h"
|
||||
#include "hal_peri_on.h"
|
||||
#include "wifi_conf.h"
|
||||
#include "rtl_consol.h"
|
||||
|
||||
#ifndef USE_SRC_ONLY_BOOT
|
||||
#define USE_SRC_ONLY_BOOT 0
|
||||
#endif
|
||||
|
||||
#if USE_SRC_ONLY_BOOT
|
||||
#define rtl_memset _memset
|
||||
#define rtl_strcmp _strcmp
|
||||
#define rtl_memcpy _memcpy
|
||||
#endif
|
||||
|
||||
#define VREG32(addr) (*((volatile uint32_t*)(addr)))
|
||||
|
||||
typedef void (*START_FUNC)(void);
|
||||
|
||||
#ifndef DEFAULT_BAUDRATE
|
||||
#define DEFAULT_BAUDRATE UART_BAUD_RATE_38400
|
||||
#endif
|
||||
|
||||
#define StartupSpicBitMode SpicDualBitMode // SpicOneBitMode
|
||||
#define StartupSpicBaudRate 0
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
void PreProcessForVendor(void); // image1
|
||||
void RtlBootToSram(void); // image1
|
||||
uint32_t StartupHalLogUartInit(uint32_t uart_irq); // image1
|
||||
void StartupHalInitPlatformLogUart(void); // image1
|
||||
int IsForceLoadDefaultImg2(void); // image1
|
||||
void StartupHalSpicInit(int InitBaudRate); // image1
|
||||
int _GetChipId(void); // image1
|
||||
void RtlConsolRam(void); // image1
|
||||
extern void UartLogIrqHandle(void * Data); // in ROM
|
||||
extern int RtlConsolRom(int); // in ROM
|
||||
extern PHAL_GPIO_ADAPTER _pHAL_Gpio_Adapter;
|
||||
extern void SpicUserReadRtl8195A(IN uint32_t Length, IN uint32_t addr, IN uint8_t * data,
|
||||
IN uint8_t BitMode);
|
||||
#if !USE_SRC_ONLY_BOOT
|
||||
void InfraStart(void);
|
||||
extern void HalWdgIntrHandle(void);
|
||||
extern int wifi_off(void); // in wifi_conf.c
|
||||
extern void xPortPendSVHandler(void);
|
||||
extern void xPortSysTickHandler(void);
|
||||
extern void vPortSVCHandler(void);
|
||||
extern void ShowRamBuildInfo(void); // app_start.c: void ShowRamBuildInfo(void)
|
||||
void HalNMIHandler_Patch(void);
|
||||
void SDIO_Device_Off(void);
|
||||
void VectorTableOverrideRtl8195A(uint32_t StackP);
|
||||
void SYSPlatformInit(void);
|
||||
void HalHardFaultHandler_Patch_c(uint32_t HardDefaultArg);
|
||||
void __HalReInitPlatformLogUart(void);
|
||||
void _ReloadImg(void);
|
||||
void _ReloadImg_user_define(void);
|
||||
void _CPUResetHandler(void);
|
||||
void _CPUReset(void);
|
||||
void HalHardFaultHandler_user_define(uint32_t HardDefaultArg);
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Data declarations
|
||||
extern START_FUNC __image2_entry_func__;
|
||||
extern uint8_t __image2_validate_code__;
|
||||
extern uint8_t __image1_bss_start__, __image1_bss_end__;
|
||||
extern uint8_t __rom_bss_start__, __rom_bss_end__;
|
||||
//extern uint32_t STACK_TOP;
|
||||
#define STACK_TOP 0x1FFFFFFC
|
||||
|
||||
#if !USE_SRC_ONLY_BOOT
|
||||
extern uint32_t * NewVectorTable; // LD: NewVectorTable = 0x10000000;
|
||||
extern uint8_t __bss_start__, __bss_end__;
|
||||
#endif
|
||||
|
||||
//extern volatile UART_LOG_CTL * pUartLogCtl;
|
||||
extern int UartLogCmdExecute(volatile uint8_t *);
|
||||
/*
|
||||
typedef struct __RAM_IMG2_VALID_PATTEN__ {
|
||||
char rtkwin[7];
|
||||
uint8_t x[13];
|
||||
} _RAM_IMG2_VALID_PATTEN, *_PRAM_IMG2_VALID_PATTEN;
|
||||
*/
|
||||
const uint8_t IMAGE1_VALID_PATTEN_SECTION RAM_IMG1_VALID_PATTEN[8] =
|
||||
{ 0x23, 0x79, 0x16, 0x88, 0xff, 0xff, 0xff, 0xff };
|
||||
|
||||
PRAM_FUNCTION_START_TABLE __attribute__((section(".data.pRamStartFun"))) pRamStartFun =
|
||||
(PRAM_FUNCTION_START_TABLE) 0x10000BC8;
|
||||
|
||||
#include <reent.h>
|
||||
|
||||
struct _reent __attribute__((section(".libc.reent"))) impure_reent = _REENT_INIT(impure_reent);
|
||||
//struct _reent * __attribute__((section(".libc.reent"))) _rtl_impure_ptr = { &impure_data };
|
||||
//struct _reent * __attribute__((at(0x1098))) __attribute__((section(".libc.reent"))) _rtl_impure_ptr = { &impure_data };
|
||||
struct _reent * __attribute__((at(0x10001c60))) __attribute__((section(".libc.reent"))) _rtl_impure_ptr = { &impure_reent };
|
||||
|
||||
/* ROM */
|
||||
MON_RAM_BSS_SECTION
|
||||
volatile UART_LOG_CTL *pUartLogCtl;
|
||||
|
||||
MON_RAM_BSS_SECTION
|
||||
UART_LOG_BUF UartLogBuf;
|
||||
|
||||
MON_RAM_BSS_SECTION
|
||||
volatile UART_LOG_CTL UartLogCtl;
|
||||
|
||||
MON_RAM_BSS_SECTION
|
||||
uint8_t *ArgvArray[MAX_ARGV]; // *ArgvArray[10] !
|
||||
|
||||
MON_RAM_BSS_SECTION
|
||||
uint8_t UartLogHistoryBuf[UART_LOG_HISTORY_LEN][UART_LOG_CMD_BUFLEN]; // UartLogHistoryBuf[5][127] !
|
||||
|
||||
|
||||
RAM_START_FUNCTION START_RAM_FUN_A_SECTION gRamStartFun =
|
||||
{ PreProcessForVendor + 1 };
|
||||
RAM_START_FUNCTION START_RAM_FUN_B_SECTION gRamPatchWAKE =
|
||||
{ RtlBootToSram + 1 };
|
||||
RAM_START_FUNCTION START_RAM_FUN_C_SECTION gRamPatchFun0 =
|
||||
{ RtlBootToSram + 1 };
|
||||
RAM_START_FUNCTION START_RAM_FUN_D_SECTION gRamPatchFun1 =
|
||||
{ RtlBootToSram + 1 };
|
||||
RAM_START_FUNCTION START_RAM_FUN_E_SECTION gRamPatchFun2 =
|
||||
{ RtlBootToSram + 1 };
|
||||
|
||||
#if !USE_SRC_ONLY_BOOT
|
||||
RAM_START_FUNCTION IMAGE2_START_RAM_FUN_SECTION gImage2EntryFun0 =
|
||||
{ InfraStart + 1 };
|
||||
#else
|
||||
RAM_START_FUNCTION IMAGE2_START_RAM_FUN_SECTION gImage2EntryFun0 =
|
||||
{ 0x100 };
|
||||
#endif // !USE_SRC_ONLY_BOOT
|
||||
_RAM_IMG2_VALID_PATTEN IMAGE2_VALID_PATTEN_SECTION RAM_IMG2_VALID_PATTEN =
|
||||
{ { IMG2_SIGN_TXT }, { 0xff, 0, 1, 1, 0, 0x95, 0x81, 1, 1, 0, 0, 0, 0 } }; // "RTKWin"
|
||||
|
||||
HAL_GPIO_ADAPTER PINMUX_RAM_DATA_SECTION gBoot_Gpio_Adapter;
|
||||
|
||||
#pragma arm section code = ".hal.ram.text"
|
||||
#pragma arm section rodata = ".hal.ram.rodata", rwdata = ".hal.ram.data", zidata = ".hal.ram.bss"
|
||||
|
||||
#if !USE_SRC_ONLY_BOOT
|
||||
//----- HalNMIHandler_Patch
|
||||
void HalNMIHandler_Patch(void) {
|
||||
DBG_8195A_HAL("RTL8195A[HAL]: %s:NMI Error!\n", __func__);
|
||||
if ( HAL_READ32(VENDOR_REG_BASE, 0) < 0)
|
||||
HalWdgIntrHandle(); // ROM: HalWdgIntrHandle = 0x3485;
|
||||
}
|
||||
#endif // !USE_SRC_ONLY_BOOT
|
||||
|
||||
|
||||
void __attribute__((section(".hal.ram.text"))) SetDebugFlgs() {
|
||||
#if CONFIG_DEBUG_LOG > 2
|
||||
ConfigDebugErr = -1;
|
||||
ConfigDebugWarn = -1;
|
||||
ConfigDebugInfo = -1;
|
||||
#elif CONFIG_DEBUG_LOG > 1
|
||||
ConfigDebugErr = -1;
|
||||
ConfigDebugWarn = -1;
|
||||
ConfigDebugInfo = 0;
|
||||
#elif CONFIG_DEBUG_LOG > 0
|
||||
ConfigDebugErr = -1;
|
||||
ConfigDebugWarn = 0;
|
||||
ConfigDebugInfo = 0;
|
||||
#else
|
||||
ConfigDebugErr = 0;
|
||||
ConfigDebugWarn = 0;
|
||||
ConfigDebugInfo = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void __attribute__((section(".hal.ram.text"))) InitSpic(void)
|
||||
{
|
||||
VREG32(0x40006000) = 0x01000300;
|
||||
VREG32(0x40006004) = 0x1;
|
||||
VREG32(0x400060E0) = 0x0B;
|
||||
VREG32(0x400060E4) = 0x3B;
|
||||
VREG32(0x400060E8) = 0x3B;
|
||||
VREG32(0x400060EC) = 0x6B;
|
||||
VREG32(0x400060F0) = 0xEB;
|
||||
VREG32(0x400060F4) = 0x02;
|
||||
VREG32(0x400060F8) = 0xA2;
|
||||
VREG32(0x400060FC) = 0xA2;
|
||||
VREG32(0x40006100) = 0x32;
|
||||
VREG32(0x40006104) = 0x38;
|
||||
VREG32(0x40006108) = 0x06;
|
||||
VREG32(0x4000610C) = 0x05;
|
||||
VREG32(0x40006110) = 0x51;
|
||||
VREG32(0x40006114) = 0x01;
|
||||
VREG32(0x40006118) = 0x03;
|
||||
VREG32(0x4000611C) = 0x20030013;
|
||||
VREG32(0x40006120) = 0x202;
|
||||
VREG32(0x40006124) = 0x0E;
|
||||
}
|
||||
|
||||
//----- StartupHalLogUartInit
|
||||
uint32_t __attribute__((section(".hal.ram.text"))) StartupHalLogUartInit(uint32_t uart_irq) {
|
||||
HAL_UART_WRITE32(UART_DLH_OFF, 0);
|
||||
|
||||
uint32_t SysClock = (HalGetCpuClk() >> 2);
|
||||
uint32_t SampleRate = (16 * DEFAULT_BAUDRATE);
|
||||
uint32_t Divisor = SysClock / SampleRate;
|
||||
uint32_t Remaind = ((SysClock * 10) / SampleRate) - (Divisor * 10);
|
||||
if (Remaind > 4) Divisor++;
|
||||
// set DLAB bit to 1
|
||||
// HAL_UART_WRITE32(UART_INTERRUPT_EN_REG_OFF, 0);
|
||||
HAL_UART_WRITE32(UART_LINE_CTL_REG_OFF, RUART_LINE_CTL_REG_DLAB_ENABLE);
|
||||
HAL_UART_WRITE32(UART_DLL_OFF, Divisor & 0xff);
|
||||
HAL_UART_WRITE32(UART_LINE_CTL_REG_OFF, 3);
|
||||
HAL_UART_WRITE32(UART_FIFO_CTL_REG_OFF, FIFO_CTL_DEFAULT_WITH_FIFO);
|
||||
HAL_UART_WRITE32(UART_INTERRUPT_EN_REG_OFF, uart_irq);
|
||||
if (uart_irq) {
|
||||
// Enable Peripheral_IRQ Setting for Log_Uart
|
||||
HAL_WRITE32(VENDOR_REG_BASE, PERIPHERAL_IRQ_EN, 0x1000000);
|
||||
// Cortex-M3 SCB->AIRCR
|
||||
HAL_WRITE32(0xE000ED00, 0x0C,
|
||||
(HAL_READ32(0xE000ED00, 0x0C) & 0x0F8FF) | 0x5FA0300);
|
||||
HAL_WRITE8(0xE000E100, 0x313, 0xE0); // HAL_WRITE8(0xE000E100, 0x313, 0xE0);
|
||||
HAL_WRITE32(0xE000E100, 0, 0x80000); // NVIC enable external interrupt[?] ?
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----- StartupHalInitPlatformLogUart
|
||||
void __attribute__((section(".hal.ram.text"))) StartupHalInitPlatformLogUart(
|
||||
void) {
|
||||
HAL_UART_READ32(UART_REV_BUF_OFF);
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN,
|
||||
HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) & (~(BIT_SOC_LOG_UART_EN))); // 40000210 &= 0xFFFFEFFF; // ~(1<<12)
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN,
|
||||
HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) | BIT_SOC_LOG_UART_EN); // 40000210 |= 0x1000u;
|
||||
ACTCK_LOG_UART_CCTRL(ON); // 40000230 |= 0x1000u;
|
||||
StartupHalLogUartInit(IER_ERBFI | IER_ELSI);
|
||||
}
|
||||
|
||||
void __attribute__((section(".hal.ram.text"))) RtlConsolRam(void)
|
||||
{
|
||||
// __asm__ __volatile__ ("cpsid f\n");
|
||||
// HalCpuClkConfig(0); // 0 - 166666666 Hz, 1 - 83333333 Hz, 2 - 41666666 Hz, 3 - 20833333 Hz, 4 - 10416666 Hz, 5 - 4000000 Hz
|
||||
// ConfigDebugErr = -1;
|
||||
// VectorTableInitRtl8195A(STACK_TOP); // 0x1FFFFFFC);
|
||||
// HalInitPlatformLogUartV02();
|
||||
// HalReInitPlatformLogUartV02();
|
||||
// HalInitPlatformTimerV02();
|
||||
__asm__ __volatile__ ("cpsie f\n");
|
||||
|
||||
DiagPrintf("\r\nRTL Console ROM: Start - press 'ESC' key, Help '?'\r\n");
|
||||
while(!pUartLogCtl->ExecuteEsc);
|
||||
pUartLogCtl->EscSTS = 0;
|
||||
pUartLogCtl->BootRdy = 1;
|
||||
DiagPrintf("\r<RTL>");
|
||||
while(1) {
|
||||
while(!pUartLogCtl->ExecuteCmd);
|
||||
UartLogCmdExecute(pUartLogCtl);
|
||||
DiagPrintf("\r<RTL>");
|
||||
pUartLogCtl->ExecuteCmd = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//----- RtlBootToSram
|
||||
void __attribute__((section(".hal.ram.text"))) RtlBootToSram(void) {
|
||||
TIMER_ADAPTER tim_adapter;
|
||||
/* JTAG On */
|
||||
ACTCK_VENDOR_CCTRL(ON);
|
||||
SLPCK_VENDOR_CCTRL(ON);
|
||||
HalPinCtrlRtl8195A(JTAG, 0, 1);
|
||||
|
||||
memset(&__rom_bss_start__, 0, &__rom_bss_end__ - &__rom_bss_start__);
|
||||
|
||||
/* Flash & LogUart On */
|
||||
HAL_PERI_ON_WRITE32(REG_GPIO_SHTDN_CTRL, 0x7FF);
|
||||
SPI_FLASH_PIN_FCTRL(ON);
|
||||
HAL_PERI_ON_WRITE32(REG_CPU_PERIPHERAL_CTRL,
|
||||
HAL_PERI_ON_READ32(REG_CPU_PERIPHERAL_CTRL) | BIT_SPI_FLSH_PIN_EN); // 400002C0 |= 0x1u;
|
||||
HAL_PERI_ON_WRITE32(REG_CPU_PERIPHERAL_CTRL,
|
||||
HAL_PERI_ON_READ32(REG_CPU_PERIPHERAL_CTRL) | BIT_LOG_UART_PIN_EN); // 400002C0 |= 0x100000u;
|
||||
|
||||
VectorTableInitRtl8195A(STACK_TOP); // 0x1FFFFFFC
|
||||
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN,
|
||||
HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) | BIT_SOC_FLASH_EN); // 40000210 |= 0x10u;
|
||||
ACTCK_FLASH_CCTRL(ON);
|
||||
SLPCK_FLASH_CCTRL(ON);
|
||||
HalPinCtrlRtl8195A(SPI_FLASH, 0, 1);
|
||||
|
||||
SpicNVMCalLoadAll();
|
||||
|
||||
HAL_SYS_CTRL_WRITE32(REG_SYS_CLK_CTRL1,
|
||||
HAL_SYS_CTRL_READ32(REG_SYS_CLK_CTRL1) & 0x8F); // VREG32(0x40000014) &= 0x8F;
|
||||
|
||||
SetDebugFlgs();
|
||||
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN,
|
||||
HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) & (~(BIT_SOC_LOG_UART_EN))); // 40000210 &= 0xFFFFEFFF; // ~(1<<12)
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN,
|
||||
HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) | BIT_SOC_LOG_UART_EN); // 40000210 |= 0x1000u;
|
||||
|
||||
ACTCK_LOG_UART_CCTRL(ON);
|
||||
// SLPCK_LOG_UART_CCTRL(ON);
|
||||
|
||||
tim_adapter.IrqHandle.IrqFun = &UartLogIrqHandle;
|
||||
tim_adapter.IrqHandle.IrqNum = UART_LOG_IRQ;
|
||||
tim_adapter.IrqHandle.Data = 0;
|
||||
tim_adapter.IrqHandle.Priority = 5;
|
||||
|
||||
StartupHalLogUartInit(0);
|
||||
VectorIrqRegisterRtl8195A(&tim_adapter.IrqHandle);
|
||||
StartupHalLogUartInit(IER_ERBFI | IER_ELSI);
|
||||
|
||||
HAL_PERI_ON_WRITE32(REG_PON_ISO_CTRL, 3); // VREG32(0x40000204) = 3;
|
||||
HAL_PERI_ON_WRITE32(REG_OSC32K_CTRL,
|
||||
HAL_PERI_ON_READ32(REG_OSC32K_CTRL) | BIT_32K_POW_CKGEN_EN); // VREG32(0x40000270) |= 1u;
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN,
|
||||
HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) | BIT_SOC_GTIMER_EN); // VREG32(0x40000210) |= 0x10000u;
|
||||
|
||||
ACTCK_TIMER_CCTRL(ON);
|
||||
SLPCK_TIMER_CCTRL(ON);
|
||||
|
||||
tim_adapter.TimerIrqPriority = 0;
|
||||
tim_adapter.TimerLoadValueUs = 0;
|
||||
tim_adapter.TimerMode = FREE_RUN_MODE;
|
||||
tim_adapter.IrqDis = 1;
|
||||
tim_adapter.TimerId = 1;
|
||||
HalTimerInitRtl8195a((PTIMER_ADAPTER) &tim_adapter);
|
||||
|
||||
SpicInitRtl8195A(1, StartupSpicBitMode); // StartupSpicBaudRate InitBaudRate 1, SpicBitMode 1 StartupSpicBitMode
|
||||
SpicFlashInitRtl8195A(StartupSpicBitMode); // SpicBitMode 1 StartupSpicBitMode
|
||||
DBG_8195A("==*== Enter Image 1.5 ====\nImg2 Sign: %s, InfaStart @ 0x%08x\n",
|
||||
&__image2_validate_code__, __image2_entry_func__);
|
||||
if (strcmp((const char * )&__image2_validate_code__, IMG2_SIGN_TXT)) {
|
||||
DBG_MISC_ERR("Invalid Image2 Signature!\n");
|
||||
RtlConsolRam();
|
||||
}
|
||||
// InitSpic();
|
||||
__image2_entry_func__();
|
||||
}
|
||||
|
||||
//----- SYSCpuClkConfig
|
||||
void __attribute__((section(".hal.ram.text"))) SYSCpuClkConfig(int ChipID, int SysCpuClk) {
|
||||
int flg = 0;
|
||||
DBG_SPIF_INFO("SYSCpuClkConfig(0x%x)\n", SysCpuClk);
|
||||
if(HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) & BIT_SOC_FLASH_EN) {
|
||||
SpicWaitWipRtl8195A(); //_SpicWaitWipDoneRefinedRtl8195A(); ???
|
||||
flg = 1;
|
||||
}
|
||||
// if (ChipID == CHIP_ID_8710AF && (!SysCpuClk)) SysCpuClk = 1;
|
||||
HalCpuClkConfig(SysCpuClk);
|
||||
HalDelayUs(1000);
|
||||
StartupHalInitPlatformLogUart();
|
||||
if (flg) {
|
||||
SpicOneBitCalibrationRtl8195A(SysCpuClk); // extern uint32_t SpicOneBitCalibrationRtl8195A(IN uint8_t SysCpuClk);
|
||||
/*
|
||||
// Disable SPI_FLASH User Mode
|
||||
HAL_SPI_WRITE32(REG_SPIC_SSIENR, 0);
|
||||
HAL_SPI_WRITE32(REG_SPIC_VALID_CMD,
|
||||
(HAL_SPI_READ32(REG_SPIC_VALID_CMD)|(FLASH_VLD_DUAL_CMDS))); */
|
||||
SpicCalibrationRtl8195A(StartupSpicBitMode, 0);
|
||||
}
|
||||
}
|
||||
|
||||
//----- IsForceLoadDefaultImg2
|
||||
int __attribute__((section(".hal.ram.text"))) IsForceLoadDefaultImg2(void) {
|
||||
uint8_t gpio_pin[4];
|
||||
HAL_GPIO_PIN GPIO_Pin;
|
||||
HAL_GPIO_PIN_STATE flg;
|
||||
int result = 0;
|
||||
|
||||
*((uint32_t *) &gpio_pin) = HAL_READ32(SPI_FLASH_BASE, FLASH_SYSTEM_DATA_ADDR + 0x08); // config data + 8
|
||||
_pHAL_Gpio_Adapter = (int) &gBoot_Gpio_Adapter;
|
||||
for(int i = 0; i < 2; i++) {
|
||||
uint8_t x = gpio_pin[i];
|
||||
if (x != 0xff) {
|
||||
GPIO_Pin.pin_name = HAL_GPIO_GetIPPinName_8195a(x & 0x7F);
|
||||
if (x & 0x80) {
|
||||
GPIO_Pin.pin_mode = DIN_PULL_LOW;
|
||||
flg = GPIO_PIN_HIGH;
|
||||
} else {
|
||||
GPIO_Pin.pin_mode = DIN_PULL_HIGH;
|
||||
flg = GPIO_PIN_LOW;
|
||||
}
|
||||
HAL_GPIO_Init_8195a(&GPIO_Pin);
|
||||
result |= HAL_GPIO_ReadPin_8195a(&GPIO_Pin) == flg;
|
||||
HAL_GPIO_DeInit_8195a(&GPIO_Pin);
|
||||
}
|
||||
}
|
||||
_pHAL_Gpio_Adapter->IrqHandle.IrqFun = NULL;
|
||||
return result;
|
||||
}
|
||||
|
||||
//----- GetChipId
|
||||
int __attribute__((section(".hal.ram.text"))) _GetChipId() {
|
||||
uint8_t chip_id = CHIP_ID_8195AM;
|
||||
if (HALEFUSEOneByteReadROM(HAL_SYS_CTRL_READ32(REG_SYS_EFUSE_CTRL), 0xF8,
|
||||
&chip_id, L25EOUTVOLTAGE) != 1)
|
||||
DBG_MISC_INFO("Get Chip ID Failed\r");
|
||||
return chip_id;
|
||||
}
|
||||
|
||||
//----- StartupHalSpicInit
|
||||
void __attribute__((section(".hal.ram.text"))) StartupHalSpicInit(
|
||||
int InitBaudRate) {
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN,
|
||||
HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) | BIT4); // HAL_SYS_CTRL_READ32
|
||||
HAL_PERI_ON_WRITE32(REG_PESOC_CLK_CTRL,
|
||||
HAL_PERI_ON_READ32(REG_PESOC_CLK_CTRL) | BIT_SOC_ACTCK_FLASH_EN | BIT_SOC_SLPCK_FLASH_EN);
|
||||
HalPinCtrlRtl8195A(SPI_FLASH,
|
||||
((HAL_SYS_CTRL_READ32(REG_SYS_SYSTEM_CFG1) & 0xF0000000)
|
||||
== 0x30000000), 1);
|
||||
SpicInitRtl8195A(InitBaudRate, StartupSpicBitMode);
|
||||
}
|
||||
|
||||
|
||||
void __attribute__((section(".hal.ram.text"))) flashcpy(uint32_t raddr, uint32_t faddr, int32_t size) {
|
||||
while(size > 0) {
|
||||
HAL_WRITE32(0, raddr, HAL_READ32(SPI_FLASH_BASE, faddr));
|
||||
raddr+=4;
|
||||
faddr+=4;
|
||||
size-=4;
|
||||
}
|
||||
}
|
||||
//----- PreProcessForVendor
|
||||
void __attribute__((section(".hal.ram.text"))) PreProcessForVendor(void) {
|
||||
START_FUNC entry_func;
|
||||
uint32_t run_image;
|
||||
uint32_t Image2Addr = *(uint32_t *)(0x1006FFFC);
|
||||
uint32_t v16 = 0, v17;
|
||||
#if 0
|
||||
uint8_t efuse0xD3_data;
|
||||
HALEFUSEOneByteReadROM(HAL_SYS_CTRL_READ32(REG_SYS_EFUSE_CTRL), 0xD3,
|
||||
&efuse0xD3_data, L25EOUTVOLTAGE);
|
||||
if (efuse0xD3_data & 1)
|
||||
#endif
|
||||
HalPinCtrlRtl8195A(JTAG, 0, 1);
|
||||
SetDebugFlgs();
|
||||
int chip_id = _GetChipId();
|
||||
int flash_enable = HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) & BIT_SOC_FLASH_EN; // v6 = ...
|
||||
int spic_init = 0;
|
||||
/// InitSpic();
|
||||
if (flash_enable) {
|
||||
entry_func = &__image2_entry_func__;
|
||||
spic_init = 1;
|
||||
} else {
|
||||
entry_func = (START_FUNC) Image2Addr;
|
||||
if (chip_id != CHIP_ID_8711AN) { // 0xFB
|
||||
StartupHalSpicInit(StartupSpicBaudRate); // BaudRate 1
|
||||
spic_init = 1;
|
||||
}
|
||||
}
|
||||
DBG_8195A("BOOT from Flash: %s\n", (flash_enable) ? "YES" : "NO");
|
||||
memset(&__image1_bss_start__, 0,
|
||||
&__image1_bss_end__ - &__image1_bss_start__);
|
||||
HalDelayUs(1000);
|
||||
int sdr_enable = 0;
|
||||
|
||||
#ifdef CONFIG_SDR_EN
|
||||
if (chip_id > CHIP_ID_8711AF || chip_id == CHIP_ID_8710AM) {
|
||||
SdrCtrlInit();
|
||||
sdr_enable = 1;
|
||||
}
|
||||
else {
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN, HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) | BIT(21));
|
||||
}
|
||||
#else
|
||||
// SdrPowerOff();
|
||||
SDR_PIN_FCTRL(OFF);
|
||||
LDO25M_CTRL(OFF);
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN, HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) | BIT(21));
|
||||
#endif
|
||||
|
||||
if (spic_init) SpicNVMCalLoadAll();
|
||||
SYSCpuClkConfig(chip_id, 0);
|
||||
StartupHalInitPlatformLogUart(); // double !?
|
||||
__asm__ __volatile__ ("cpsie f\n");
|
||||
DBG_8195A("===== Enter Image 1 ====\n");
|
||||
if (spic_init) {
|
||||
SpicReadIDRtl8195A();
|
||||
SpicFlashInitRtl8195A(StartupSpicBitMode); // SpicBitMode 1
|
||||
}
|
||||
#ifdef CONFIG_SDR_EN
|
||||
if (sdr_enable) SdrControllerInit();
|
||||
#endif
|
||||
if (flash_enable) {
|
||||
|
||||
uint32_t img1size = (*(uint16_t *) (SPI_FLASH_BASE + 0x18)) << 10; // size in 1024 bytes
|
||||
if (img1size == 0 || img1size >= 0x3FFFC00)
|
||||
img1size = *(uint32_t *) (SPI_FLASH_BASE + 0x10) + 32;
|
||||
uint32_t * prdflash = (uint32_t *) (img1size + SPI_FLASH_BASE + 8);
|
||||
uint32_t sign1 = *prdflash++;
|
||||
uint32_t sign2 = *prdflash;
|
||||
{
|
||||
v16 = -1;
|
||||
v17 = -1;
|
||||
if (sign2 == IMG_SIGN2_RUN) {
|
||||
if (sign1 == IMG_SIGN1_RUN) {
|
||||
v16 = img1size;
|
||||
v17 = -1;
|
||||
} else if (sign1 == IMG_SIGN1_SWP) {
|
||||
v17 = img1size;
|
||||
v16 = -1;
|
||||
}
|
||||
}
|
||||
uint32_t OTA_addr = *(uint32_t *) (SPI_FLASH_BASE + FLASH_SYSTEM_DATA_ADDR); // config sector data
|
||||
if (OTA_addr != -1) {
|
||||
uint32_t image2size = *(uint32_t *) (img1size + SPI_FLASH_BASE);
|
||||
if (OTA_addr >= (img1size + image2size)
|
||||
&& !(OTA_addr & 0xFFF)) {
|
||||
prdflash = (uint32_t *) (OTA_addr + SPI_FLASH_BASE + 8);
|
||||
sign1 = *prdflash++;
|
||||
sign2 = *prdflash;
|
||||
if (sign2 == IMG_SIGN2_RUN) {
|
||||
if (sign1 == IMG_SIGN1_RUN) v16 = OTA_addr;
|
||||
else if (sign1 == IMG_SIGN1_SWP) v17 = OTA_addr;
|
||||
}
|
||||
LABEL_41: if (IsForceLoadDefaultImg2()) {
|
||||
if (v17 != -1) run_image = v17;
|
||||
else {
|
||||
run_image = v16;
|
||||
if (run_image == -1) {
|
||||
DiagPrintf("Fatal: no fw\n");
|
||||
RtlConsolRam();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (v16 != -1) run_image = v16;
|
||||
else {
|
||||
run_image = v17;
|
||||
if (run_image == -1) {
|
||||
DiagPrintf("Fatal: no fw\n");
|
||||
RtlConsolRam();
|
||||
}
|
||||
}
|
||||
}
|
||||
uint8_t * pstr;
|
||||
if (run_image == v17)
|
||||
pstr = "load OLD fw %d\n";
|
||||
else {
|
||||
if (run_image != v16) {
|
||||
LABEL_55: prdflash = run_image + SPI_FLASH_BASE;
|
||||
uint32_t img_size = *prdflash++;
|
||||
uint32_t Image2Addr = *prdflash;
|
||||
DBG_8195A("Flash Image2: Addr 0x%x, Len %d, Load to SRAM 0x%x\n", run_image, img_size, Image2Addr); // debug!
|
||||
flashcpy(Image2Addr, run_image+16, img_size);
|
||||
// SpicUserReadFourByteRtl8195A(img_size, run_image + 16, Image2Addr, StartupSpicBitMode); // SpicDualBitMode
|
||||
prdflash = run_image + img_size + SPI_FLASH_BASE + 16;
|
||||
uint32_t sdram_image_size = *prdflash++; // +0x10
|
||||
uint32_t sdram_load_addr = *prdflash; // +0x14
|
||||
DBG_8195A("Image3 length: 0x%x, Image3 Addr: 0x%x\n",
|
||||
sdram_image_size, sdram_load_addr);
|
||||
if ((sdram_image_size - 1) <= 0xFFFFFFFD
|
||||
&& *((uint32_t *)(sdram_load_addr)) == SDR_SDRAM_BASE) { // sdram_load_addr
|
||||
if (!sdr_enable) {
|
||||
DBG_MISC_ERR("FW/HW conflict. No DRAM on board.\n");
|
||||
RtlConsolRam();
|
||||
}
|
||||
DBG_8195A("Image3 length: 0x%x, Image3 Addr: 0x%x\n",
|
||||
sdram_image_size, sdram_load_addr);
|
||||
// SpicUserReadRtl8195A(sdram_image_size, run_image + img_size + 32, SDR_SDRAM_BASE, StartupSpicBitMode);
|
||||
} else DBG_8195A("No Image3\n");
|
||||
|
||||
entry_func = *(uint32_t *)Image2Addr;
|
||||
DBG_8195A("Img2 Sign: %s, InfaStart @ 0x%08x \n",
|
||||
(const char * )(Image2Addr + 4),
|
||||
entry_func); // *(uint32_t *)Image2Addr);
|
||||
if (strcmp((const char * )(Image2Addr + 4),
|
||||
IMG2_SIGN_TXT)) {
|
||||
DBG_MISC_ERR("Invalid Image2 Signature\n");
|
||||
RtlConsolRam();
|
||||
}
|
||||
#if 0
|
||||
DBG_8195A("CLK CPU: %d Hz\n", HalGetCpuClk());
|
||||
RtlConsolRam();
|
||||
#else
|
||||
#endif
|
||||
(void) (entry_func)();
|
||||
return;
|
||||
}
|
||||
pstr = "load NEW fw %d\n";
|
||||
} // if (run_image == v17) else
|
||||
DiagPrintf(pstr, ((run_image - OTA_addr) <= 0));
|
||||
goto LABEL_55;
|
||||
}
|
||||
DBG_MISC_ERR("OTA addr 0x%x INVALID\n", OTA_addr);
|
||||
}
|
||||
OTA_addr = -1;
|
||||
goto LABEL_41;
|
||||
}
|
||||
} // if (flash_enable)
|
||||
if (strcmp((const char * )(Image2Addr + 4), IMG2_SIGN_TXT)) {
|
||||
DBG_MISC_ERR("Invalid Image2 Signature\n", 2 * ConfigDebugErr);
|
||||
RtlConsolRam();
|
||||
}
|
||||
(void) (entry_func)();
|
||||
}
|
||||
|
||||
#if !USE_SRC_ONLY_BOOT
|
||||
//----- HalHardFaultHandler_Patch_c
|
||||
void HalHardFaultHandler_Patch_c(uint32_t HardDefaultArg) {
|
||||
uint32_t v1;
|
||||
int v2;
|
||||
int v3;
|
||||
|
||||
v1 = HardDefaultArg;
|
||||
if ((VREG32(0xE000ED28) & 0x82)
|
||||
&& (unsigned int) (VREG32(0xE000ED38) - 0x40080000) < 0x40000) {
|
||||
DBG_8195A("\n.");
|
||||
v2 = *(uint32_t *) (v1 + 24);
|
||||
if ((*(uint16_t *) v2 & 0xF800) <= 0xE000) v3 = v2 + 2;
|
||||
else v3 = v2 + 4;
|
||||
*(uint32_t *) (v1 + 24) = v3;
|
||||
} else {
|
||||
HalHardFaultHandler_user_define(HardDefaultArg);
|
||||
HalHardFaultHandler(v1); // ROM: HalHardFaultHandler = 0x911;
|
||||
}
|
||||
}
|
||||
|
||||
//----- VectorTableOverrideRtl8195A
|
||||
void __attribute__((section(".infra.ram.start"))) VectorTableOverrideRtl8195A(uint32_t StackP) {
|
||||
NewVectorTable[2] = HalNMIHandler_Patch;
|
||||
}
|
||||
|
||||
//----- SYSPlatformInit
|
||||
void __attribute__((section(".infra.ram.start"))) SYSPlatformInit(void) {
|
||||
HAL_SYS_CTRL_WRITE32(REG_SYS_EFUSE_SYSCFG0,
|
||||
(HAL_SYS_CTRL_READ32(REG_SYS_EFUSE_SYSCFG0) & (~(BIT_MASK_SYS_EEROM_LDO_PAR_07_04 << BIT_SHIFT_SYS_EEROM_LDO_PAR_07_04))) | BIT_SYS_EEROM_LDO_PAR_07_04(6)); // & 0xF0FFFFFF | 0x6000000
|
||||
HAL_SYS_CTRL_WRITE32(REG_SYS_XTAL_CTRL1,
|
||||
(HAL_SYS_CTRL_READ32(REG_SYS_XTAL_CTRL1) & (~(BIT_MASK_SYS_XTAL_DRV_RF1 << BIT_SHIFT_SYS_XTAL_DRV_RF1))) | BIT_SYS_XTAL_DRV_RF1(1)); // & 0xFFFFFFE7 | 8;
|
||||
}
|
||||
|
||||
//----- InfraStart
|
||||
void __attribute__((section(".infra.ram.start"))) InfraStart(void) {
|
||||
NewVectorTable[2] = HalNMIHandler_Patch;
|
||||
HAL_SYS_CTRL_WRITE32(REG_SYS_CLK_CTRL0,
|
||||
HAL_SYS_CTRL_READ32(REG_SYS_CLK_CTRL0) | BIT4);
|
||||
if (HalCommonInit() != HAL_OK) DBG_8195A("Hal Common Init Failed.\n");
|
||||
DBG_8195A("===== Enter Image 2 ====\n");
|
||||
ShowRamBuildInfo(); // app_start.c: void ShowRamBuildInfo(void)
|
||||
memset(&__bss_start__, 0, &__bss_end__ - &__bss_start__);
|
||||
int flsh = (HAL_SYS_CTRL_READ32(REG_SYS_CLK_CTRL0)
|
||||
>> BIT_SHIFT_PESOC_OCP_CPU_CK_SEL) & 1;
|
||||
if (flsh) {
|
||||
SpicNVMCalLoadAll();
|
||||
SpicReadIDRtl8195A();
|
||||
}
|
||||
SystemCoreClockUpdate();
|
||||
SYSPlatformInit();
|
||||
En32KCalibration();
|
||||
InitSoCPM();
|
||||
SDIO_Device_Off();
|
||||
VectorTableInitForOSRtl8195A(&vPortSVCHandler, &xPortPendSVHandler, &xPortSysTickHandler);
|
||||
if (flsh) SpicDisableRtl8195A();
|
||||
_AppStart();
|
||||
}
|
||||
|
||||
//----- SDIO_Device_Off
|
||||
void SDIO_Device_Off(void) {
|
||||
HAL_PERI_ON_WRITE32(REG_PESOC_HCI_CLK_CTRL0,
|
||||
HAL_PERI_ON_READ32(REG_PESOC_HCI_CLK_CTRL0) & (~BIT_SOC_ACTCK_SDIO_DEV_EN));
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_HCI_COM_FUNC_EN,
|
||||
HAL_PERI_ON_READ32(REG_SOC_HCI_COM_FUNC_EN) & (~(BIT_SOC_HCI_SDIOD_ON_EN | BIT_SOC_HCI_SDIOD_OFF_EN)));
|
||||
HAL_PERI_ON_WRITE32(REG_HCI_PINMUX_CTRL,
|
||||
HAL_PERI_ON_READ32(REG_HCI_PINMUX_CTRL) & (~(BIT_HCI_SDIOD_PIN_EN)));
|
||||
}
|
||||
|
||||
//----- __HalReInitPlatformLogUart
|
||||
void __HalReInitPlatformLogUart(void) {
|
||||
LOG_UART_ADAPTER UartAdapter;
|
||||
UartAdapter.BaudRate = DEFAULT_BAUDRATE;
|
||||
HalLogUartInit(UartAdapter);
|
||||
}
|
||||
|
||||
void _ReloadImg_user_define(void) {
|
||||
|
||||
}
|
||||
|
||||
//----- ReloadImg
|
||||
void _ReloadImg(void) {
|
||||
uint32_t img1size;
|
||||
uint32_t img1addr;
|
||||
unsigned int i;
|
||||
uint32_t img2addr;
|
||||
uint32_t img_addr1;
|
||||
uint32_t img_addr2;
|
||||
uint32_t ota_addr;
|
||||
const char * pstr;
|
||||
|
||||
img1size = *(uint32_t *) (SPI_FLASH_BASE + 0x10);
|
||||
img1addr = *(uint32_t *) (SPI_FLASH_BASE + 0x14);
|
||||
DBG_8195A("Image1 length: 0x%x, Image Addr: 0x%x\n", img1size,
|
||||
img1addr);
|
||||
for (i = 32; i < img1size + 32; i += 4)
|
||||
*(uint32_t *) (img1addr - 32 + i) = *(uint32_t *) (i + SPI_FLASH_BASE);
|
||||
img2addr = *(uint16_t *) (SPI_FLASH_BASE + 0x16) << 10;
|
||||
if (!(img2addr)) img2addr = img1size + 32;
|
||||
uint32_t * prdflash = (uint32_t *) (img1size + SPI_FLASH_BASE + 8);
|
||||
uint32_t sign1 = *prdflash++; // v4 = *(uint32_t *)(img2addr + SPI_FLASH_BASE + 8);
|
||||
uint32_t sign2 = *prdflash; // v5 = *(uint32_t *)(img2addr + SPI_FLASH_BASE + 12);
|
||||
if (sign1 == IMG_SIGN1_RUN) {
|
||||
if (sign2 == IMG_SIGN2_RUN) {
|
||||
img_addr1 = img2addr;
|
||||
LABEL_11: img_addr2 = -1;
|
||||
goto LABEL_16;
|
||||
}
|
||||
LABEL_14: img_addr1 = -1;
|
||||
goto LABEL_11;
|
||||
}
|
||||
if (sign1 != IMG_SIGN1_SWP || sign2 != IMG_SIGN2_RUN) goto LABEL_14;
|
||||
img_addr2 = img2addr;
|
||||
img_addr1 = -1;
|
||||
LABEL_16: ota_addr = *(uint32_t *) (SPI_FLASH_BASE + 0x9000);
|
||||
if (ota_addr == -1) {
|
||||
LABEL_21: ota_addr = -1;
|
||||
goto LABEL_22;
|
||||
}
|
||||
if (ota_addr < (img2addr + *(uint32_t *) (img2addr + SPI_FLASH_BASE))
|
||||
|| (ota_addr & 0xFFF)) {
|
||||
DBG_MISC_ERR("OTA addr 0x%x INVALID\n");
|
||||
goto LABEL_21;
|
||||
}
|
||||
prdflash = (uint32_t *) (ota_addr + SPI_FLASH_BASE + 8);
|
||||
sign1 = *prdflash++; // v9 = *(uint32_t *)(ota_addr + SPI_FLASH_BASE + 8);
|
||||
sign2 = *prdflash; // v11 = *(uint32_t *)(ota_addr + SPI_FLASH_BASE + 12);
|
||||
if (sign1 == IMG_SIGN1_RUN) {
|
||||
sign1 = IMG_SIGN2_RUN;
|
||||
if (sign2 == IMG_SIGN2_RUN) {
|
||||
img_addr1 = ota_addr;
|
||||
goto LABEL_33;
|
||||
}
|
||||
goto LABEL_22;
|
||||
}
|
||||
if (sign1 != IMG_SIGN1_SWP || (sign1 = IMG_SIGN2_RUN, sign2 != IMG_SIGN2_RUN)) {
|
||||
LABEL_22: if (img_addr1 == -1) {
|
||||
if (img_addr2 == -1) {
|
||||
DBG_MISC_ERR("Fatal:no fw\n", ota_addr,
|
||||
2 * ConfigDebugErr);
|
||||
RtlConsolRam();
|
||||
}
|
||||
img_addr1 = img_addr2;
|
||||
LABEL_28: pstr = "load OLD fw %d\n";
|
||||
if (ConfigDebugErr & _DBG_MISC_) {
|
||||
LABEL_36: DiagPrintf(pstr,
|
||||
((unsigned int) (img_addr1 - ota_addr) <= 0));
|
||||
}
|
||||
goto IMG2_LOAD_START;
|
||||
}
|
||||
goto LABEL_33;
|
||||
}
|
||||
if (img_addr1 == -1) {
|
||||
img_addr1 = *(uint32_t *) (SPI_FLASH_BASE + 0x9000); // ota_addr
|
||||
goto LABEL_28;
|
||||
}
|
||||
img_addr2 = *(uint32_t *) (SPI_FLASH_BASE + 0x9000);
|
||||
LABEL_33: if (img_addr1 == img_addr2)
|
||||
goto LABEL_28;
|
||||
if (ConfigDebugErr & _DBG_MISC_) // DBG_8195A
|
||||
{
|
||||
pstr = "load NEW fw %d\n";
|
||||
goto LABEL_36;
|
||||
}
|
||||
uint32_t v13;
|
||||
IMG2_LOAD_START:
|
||||
v13 = *(uint32_t *) (img_addr1 + SPI_FLASH_BASE + 4);
|
||||
uint32_t v15 = *(uint32_t *) (img_addr1 + SPI_FLASH_BASE) + img_addr1;
|
||||
for (i = img_addr1 + 16;; i += 4) {
|
||||
if (i >= (unsigned int) (v15 + 16)) break;
|
||||
*(uint32_t *) (v13 - 16 - img_addr1 + i) = *(uint32_t *) (i + SPI_FLASH_BASE);
|
||||
}
|
||||
uint32_t v16 = *(uint32_t *) (v15 + SPI_FLASH_BASE);
|
||||
if ((unsigned int) (v16 - 1) <= 0xFFFFFFFD
|
||||
&& *(uint32_t *) (v15 + SPI_FLASH_BASE + 0x14) == 0x30000000) {
|
||||
DBG_8195A("Image3 length: 0x%x, Image3 Addr: 0x%x\n",
|
||||
*(uint32_t *)(v15 + SPI_FLASH_BASE + 0x10));
|
||||
for (i = v15 + 32; i < (v16 + v15 + 32); i += 4)
|
||||
*(uint32_t *) (0x2FFFFFE0 - v15 + i) = *(uint32_t *) (i + SPI_FLASH_BASE);
|
||||
} else
|
||||
DBG_8195A("No Image3\n");
|
||||
_ReloadImg_user_define();
|
||||
}
|
||||
|
||||
//----- CPUResetHandler
|
||||
void _CPUResetHandler(void) {
|
||||
memset(&__rom_bss_start__, 0, &__rom_bss_end__ - &__rom_bss_start__);
|
||||
|
||||
ConfigDebugErr = -1;
|
||||
|
||||
HalCpuClkConfig(0);
|
||||
VectorTableInitRtl8195A(STACK_TOP); // 0x1FFFFFFC
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN,
|
||||
HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) & BIT23);
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN,
|
||||
HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) & BIT_SOC_FLASH_EN);
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_PERI_BD_FUNC0_EN,
|
||||
HAL_PERI_ON_READ32(REG_SOC_PERI_BD_FUNC0_EN) | BIT8 | BIT9);
|
||||
HalPinCtrlRtl8195A(SPI_FLASH, 0, 1);
|
||||
HalTimerOpInit_Patch(&HalTimerOp);
|
||||
HalDelayUs(1000);
|
||||
__HalReInitPlatformLogUart();
|
||||
_ReloadImg();
|
||||
InfraStart();
|
||||
}
|
||||
//----- CPUReset
|
||||
void _CPUReset(void) // __noreturn
|
||||
{
|
||||
wifi_off();
|
||||
pRamStartFun->RamPatchFun1 = _CPUResetHandler;
|
||||
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN,
|
||||
HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) & BIT27);
|
||||
HAL_WRITE32(0xE000ED00, 0x0C, 0x5FA0003); //
|
||||
while (1);
|
||||
}
|
||||
|
||||
void HalHardFaultHandler_user_define(uint32_t HardDefaultArg) {
|
||||
|
||||
}
|
||||
#endif // !USE_SRC_ONLY_BOOT
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef RTL8195A_OTG_ZERO_H
|
||||
#define RTL8195A_OTG_ZERO_H
|
||||
|
||||
#include "usb_ch9.h"
|
||||
#include "usb_gadget.h"
|
||||
|
||||
struct zero_dev {
|
||||
//ModifiedByJD spinlock_t lock;
|
||||
struct usb_gadget *gadget;
|
||||
struct usb_request *req; /* for control responses */
|
||||
|
||||
/* when configured, we have one of two configs:
|
||||
* - source data (in to host) and sink it (out from host)
|
||||
* - or loop it back (out from host back in to host)
|
||||
*/
|
||||
u8 config;
|
||||
struct usb_ep *in_ep, *out_ep, *status_ep;//ModifiedByJD
|
||||
|
||||
const struct usb_endpoint_descriptor
|
||||
*in, *out, *status; //ModifiedByJD
|
||||
/* autoresume timer */
|
||||
//ModifiedByJD struct timer_list resume;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,211 @@
|
|||
|
||||
//#include "../otg/osk/sys-support.h" //ModifiedByJD
|
||||
|
||||
/*
|
||||
* USB Communications Device Class (CDC) definitions
|
||||
*
|
||||
* CDC says how to talk to lots of different types of network adapters,
|
||||
* notably ethernet adapters and various modems. It's used mostly with
|
||||
* firmware based USB peripherals.
|
||||
*/
|
||||
|
||||
#define USB_CDC_SUBCLASS_ACM 0x02
|
||||
#define USB_CDC_SUBCLASS_ETHERNET 0x06
|
||||
#define USB_CDC_SUBCLASS_WHCM 0x08
|
||||
#define USB_CDC_SUBCLASS_DMM 0x09
|
||||
#define USB_CDC_SUBCLASS_MDLM 0x0a
|
||||
#define USB_CDC_SUBCLASS_OBEX 0x0b
|
||||
|
||||
#define USB_CDC_PROTO_NONE 0
|
||||
|
||||
#define USB_CDC_ACM_PROTO_AT_V25TER 1
|
||||
#define USB_CDC_ACM_PROTO_AT_PCCA101 2
|
||||
#define USB_CDC_ACM_PROTO_AT_PCCA101_WAKE 3
|
||||
#define USB_CDC_ACM_PROTO_AT_GSM 4
|
||||
#define USB_CDC_ACM_PROTO_AT_3G 5
|
||||
#define USB_CDC_ACM_PROTO_AT_CDMA 6
|
||||
#define USB_CDC_ACM_PROTO_VENDOR 0xff
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//#define UPACKED __attribute__ ((packed))
|
||||
#define UPACKED
|
||||
/*
|
||||
* Class-Specific descriptors ... there are a couple dozen of them
|
||||
*/
|
||||
|
||||
#define USB_CDC_HEADER_TYPE 0x00 /* header_desc */
|
||||
#define USB_CDC_CALL_MANAGEMENT_TYPE 0x01 /* call_mgmt_descriptor */
|
||||
#define USB_CDC_ACM_TYPE 0x02 /* acm_descriptor */
|
||||
#define USB_CDC_UNION_TYPE 0x06 /* union_desc */
|
||||
#define USB_CDC_COUNTRY_TYPE 0x07
|
||||
#define USB_CDC_NETWORK_TERMINAL_TYPE 0x0a /* network_terminal_desc */
|
||||
#define USB_CDC_ETHERNET_TYPE 0x0f /* ether_desc */
|
||||
#define USB_CDC_WHCM_TYPE 0x11
|
||||
#define USB_CDC_MDLM_TYPE 0x12 /* mdlm_desc */
|
||||
#define USB_CDC_MDLM_DETAIL_TYPE 0x13 /* mdlm_detail_desc */
|
||||
#define USB_CDC_DMM_TYPE 0x14
|
||||
#define USB_CDC_OBEX_TYPE 0x15
|
||||
|
||||
//ModifiedByJD (>>>) modify the data type to useable ones.
|
||||
/* "Header Functional Descriptor" from CDC spec 5.2.3.1 */
|
||||
struct usb_cdc_header_desc {
|
||||
u8 bLength;
|
||||
u8 bDescriptorType;
|
||||
u8 bDescriptorSubType;
|
||||
|
||||
u16 bcdCDC;
|
||||
} UPACKED;
|
||||
|
||||
/* "Call Management Descriptor" from CDC spec 5.2.3.2 */
|
||||
struct usb_cdc_call_mgmt_descriptor {
|
||||
u8 bLength;
|
||||
u8 bDescriptorType;
|
||||
u8 bDescriptorSubType;
|
||||
|
||||
u8 bmCapabilities;
|
||||
#define USB_CDC_CALL_MGMT_CAP_CALL_MGMT 0x01
|
||||
#define USB_CDC_CALL_MGMT_CAP_DATA_INTF 0x02
|
||||
|
||||
u8 bDataInterface;
|
||||
} UPACKED;
|
||||
|
||||
/* "Abstract Control Management Descriptor" from CDC spec 5.2.3.3 */
|
||||
struct usb_cdc_acm_descriptor {
|
||||
u8 bLength;
|
||||
u8 bDescriptorType;
|
||||
u8 bDescriptorSubType;
|
||||
|
||||
u8 bmCapabilities;
|
||||
} UPACKED;
|
||||
|
||||
/* "Union Functional Descriptor" from CDC spec 5.2.3.8 */
|
||||
struct usb_cdc_union_desc {
|
||||
u8 bLength;
|
||||
u8 bDescriptorType;
|
||||
u8 bDescriptorSubType;
|
||||
|
||||
u8 bMasterInterface0;
|
||||
u8 bSlaveInterface0;
|
||||
/* ... and there could be other slave interfaces */
|
||||
} UPACKED;
|
||||
|
||||
/* "Network Channel Terminal Functional Descriptor" from CDC spec 5.2.3.11 */
|
||||
struct usb_cdc_network_terminal_desc {
|
||||
u8 bLength;
|
||||
u8 bDescriptorType;
|
||||
u8 bDescriptorSubType;
|
||||
|
||||
u8 bEntityId;
|
||||
u8 iName;
|
||||
u8 bChannelIndex;
|
||||
u8 bPhysicalInterface;
|
||||
} UPACKED;
|
||||
|
||||
/* "Ethernet Networking Functional Descriptor" from CDC spec 5.2.3.16 */
|
||||
struct usb_cdc_ether_desc {
|
||||
u8 bLength;
|
||||
u8 bDescriptorType;
|
||||
u8 bDescriptorSubType;
|
||||
|
||||
u8 iMACAddress;
|
||||
u32 bmEthernetStatistics;
|
||||
u16 wMaxSegmentSize;
|
||||
u16 wNumberMCFilters;
|
||||
u8 bNumberPowerFilters;
|
||||
} UPACKED;
|
||||
|
||||
/* "MDLM Functional Descriptor" from CDC WMC spec 6.7.2.3 */
|
||||
struct usb_cdc_mdlm_desc {
|
||||
u8 bLength;
|
||||
u8 bDescriptorType;
|
||||
u8 bDescriptorSubType;
|
||||
|
||||
u16 bcdVersion;
|
||||
u8 bGUID[16];
|
||||
}UPACKED;
|
||||
|
||||
/* "MDLM Detail Functional Descriptor" from CDC WMC spec 6.7.2.4 */
|
||||
struct usb_cdc_mdlm_detail_desc {
|
||||
u8 bLength;
|
||||
u8 bDescriptorType;
|
||||
u8 bDescriptorSubType;
|
||||
|
||||
/* type is associated with mdlm_desc.bGUID */
|
||||
u8 bGuidDescriptorType;
|
||||
u8 bDetailData[0];
|
||||
} UPACKED;
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Class-Specific Control Requests (6.2)
|
||||
*
|
||||
* section 3.6.2.1 table 4 has the ACM profile, for modems.
|
||||
* section 3.8.2 table 10 has the ethernet profile.
|
||||
*
|
||||
* Microsoft's RNDIS stack for Ethernet is a vendor-specific CDC ACM variant,
|
||||
* heavily dependent on the encapsulated (proprietary) command mechanism.
|
||||
*/
|
||||
|
||||
#define USB_CDC_SEND_ENCAPSULATED_COMMAND 0x00
|
||||
#define USB_CDC_GET_ENCAPSULATED_RESPONSE 0x01
|
||||
#define USB_CDC_REQ_SET_LINE_CODING 0x20
|
||||
#define USB_CDC_REQ_GET_LINE_CODING 0x21
|
||||
#define USB_CDC_REQ_SET_CONTROL_LINE_STATE 0x22
|
||||
#define USB_CDC_REQ_SEND_BREAK 0x23
|
||||
#define USB_CDC_SET_ETHERNET_MULTICAST_FILTERS 0x40
|
||||
#define USB_CDC_SET_ETHERNET_PM_PATTERN_FILTER 0x41
|
||||
#define USB_CDC_GET_ETHERNET_PM_PATTERN_FILTER 0x42
|
||||
#define USB_CDC_SET_ETHERNET_PACKET_FILTER 0x43
|
||||
#define USB_CDC_GET_ETHERNET_STATISTIC 0x44
|
||||
|
||||
/* Line Coding Structure from CDC spec 6.2.13 */
|
||||
struct usb_cdc_line_coding {
|
||||
u32 dwDTERate;
|
||||
u8 bCharFormat;
|
||||
#define USB_CDC_1_STOP_BITS 0
|
||||
#define USB_CDC_1_5_STOP_BITS 1
|
||||
#define USB_CDC_2_STOP_BITS 2
|
||||
|
||||
u8 bParityType;
|
||||
#define USB_CDC_NO_PARITY 0
|
||||
#define USB_CDC_ODD_PARITY 1
|
||||
#define USB_CDC_EVEN_PARITY 2
|
||||
#define USB_CDC_MARK_PARITY 3
|
||||
#define USB_CDC_SPACE_PARITY 4
|
||||
|
||||
u8 bDataBits;
|
||||
} UPACKED;
|
||||
|
||||
/* table 62; bits in multicast filter */
|
||||
#define USB_CDC_PACKET_TYPE_PROMISCUOUS (1 << 0)
|
||||
#define USB_CDC_PACKET_TYPE_ALL_MULTICAST (1 << 1) /* no filter */
|
||||
#define USB_CDC_PACKET_TYPE_DIRECTED (1 << 2)
|
||||
#define USB_CDC_PACKET_TYPE_BROADCAST (1 << 3)
|
||||
#define USB_CDC_PACKET_TYPE_MULTICAST (1 << 4) /* filtered */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Class-Specific Notifications (6.3) sent by interrupt transfers
|
||||
*
|
||||
* section 3.8.2 table 11 of the CDC spec lists Ethernet notifications
|
||||
* section 3.6.2.1 table 5 specifies ACM notifications, accepted by RNDIS
|
||||
* RNDIS also defines its own bit-incompatible notifications
|
||||
*/
|
||||
|
||||
#define USB_CDC_NOTIFY_NETWORK_CONNECTION 0x00
|
||||
#define USB_CDC_NOTIFY_RESPONSE_AVAILABLE 0x01
|
||||
#define USB_CDC_NOTIFY_SERIAL_STATE 0x20
|
||||
#define USB_CDC_NOTIFY_SPEED_CHANGE 0x2a
|
||||
|
||||
struct usb_cdc_notification {
|
||||
u8 bmRequestType;
|
||||
u8 bNotificationType;
|
||||
u16 wValue;
|
||||
u16 wIndex;
|
||||
u16 wLength;
|
||||
}UPACKED;
|
||||
//ModifiedByJD (<<<)
|
||||
|
||||
|
|
@ -0,0 +1,594 @@
|
|||
/* $OpenBSD: queue.h,v 1.26 2004/05/04 16:59:32 grange Exp $ */
|
||||
/* $NetBSD: queue.h,v 1.11 1996/05/16 05:17:14 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1991, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)queue.h 8.5 (Berkeley) 8/20/94
|
||||
*/
|
||||
|
||||
#ifndef _DWC_LIST_H_
|
||||
#define _DWC_LIST_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @file
|
||||
*
|
||||
* This file defines linked list operations. It is derived from BSD with
|
||||
* only the MACRO names being prefixed with DWC_. This is because a few of
|
||||
* these names conflict with those on Linux. For documentation on use, see the
|
||||
* inline comments in the source code. The original license for this source
|
||||
* code applies and is preserved in the dwc_list.h source file.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file defines five types of data structures: singly-linked lists,
|
||||
* lists, simple queues, tail queues, and circular queues.
|
||||
*
|
||||
*
|
||||
* A singly-linked list is headed by a single forward pointer. The elements
|
||||
* are singly linked for minimum space and pointer manipulation overhead at
|
||||
* the expense of O(n) removal for arbitrary elements. New elements can be
|
||||
* added to the list after an existing element or at the head of the list.
|
||||
* Elements being removed from the head of the list should use the explicit
|
||||
* macro for this purpose for optimum efficiency. A singly-linked list may
|
||||
* only be traversed in the forward direction. Singly-linked lists are ideal
|
||||
* for applications with large datasets and few or no removals or for
|
||||
* implementing a LIFO queue.
|
||||
*
|
||||
* A list is headed by a single forward pointer (or an array of forward
|
||||
* pointers for a hash table header). The elements are doubly linked
|
||||
* so that an arbitrary element can be removed without a need to
|
||||
* traverse the list. New elements can be added to the list before
|
||||
* or after an existing element or at the head of the list. A list
|
||||
* may only be traversed in the forward direction.
|
||||
*
|
||||
* A simple queue is headed by a pair of pointers, one the head of the
|
||||
* list and the other to the tail of the list. The elements are singly
|
||||
* linked to save space, so elements can only be removed from the
|
||||
* head of the list. New elements can be added to the list before or after
|
||||
* an existing element, at the head of the list, or at the end of the
|
||||
* list. A simple queue may only be traversed in the forward direction.
|
||||
*
|
||||
* A tail queue is headed by a pair of pointers, one to the head of the
|
||||
* list and the other to the tail of the list. The elements are doubly
|
||||
* linked so that an arbitrary element can be removed without a need to
|
||||
* traverse the list. New elements can be added to the list before or
|
||||
* after an existing element, at the head of the list, or at the end of
|
||||
* the list. A tail queue may be traversed in either direction.
|
||||
*
|
||||
* A circle queue is headed by a pair of pointers, one to the head of the
|
||||
* list and the other to the tail of the list. The elements are doubly
|
||||
* linked so that an arbitrary element can be removed without a need to
|
||||
* traverse the list. New elements can be added to the list before or after
|
||||
* an existing element, at the head of the list, or at the end of the list.
|
||||
* A circle queue may be traversed in either direction, but has a more
|
||||
* complex end of list detection.
|
||||
*
|
||||
* For details on the use of these macros, see the queue(3) manual page.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Double-linked List.
|
||||
*/
|
||||
|
||||
typedef struct dwc_list_link {
|
||||
struct dwc_list_link *next;
|
||||
struct dwc_list_link *prev;
|
||||
} dwc_list_link_t;
|
||||
|
||||
#define DWC_LIST_INIT(link) do { \
|
||||
(link)->next = (link); \
|
||||
(link)->prev = (link); \
|
||||
} while (0)
|
||||
|
||||
#define DWC_LIST_FIRST(link) ((link)->next)
|
||||
#define DWC_LIST_LAST(link) ((link)->prev)
|
||||
#define DWC_LIST_END(link) (link)
|
||||
#define DWC_LIST_NEXT(link) ((link)->next)
|
||||
#define DWC_LIST_PREV(link) ((link)->prev)
|
||||
#define DWC_LIST_EMPTY(link) \
|
||||
(DWC_LIST_FIRST(link) == DWC_LIST_END(link))
|
||||
#define DWC_LIST_ENTRY(link, type, field) \
|
||||
(type *)((uint8_t *)(link) - (size_t)(&((type *)0)->field))
|
||||
|
||||
#if 0
|
||||
#define DWC_LIST_INSERT_HEAD(list, link) do { \
|
||||
(link)->next = (list)->next; \
|
||||
(link)->prev = (list); \
|
||||
(list)->next->prev = (link); \
|
||||
(list)->next = (link); \
|
||||
} while (0)
|
||||
|
||||
#define DWC_LIST_INSERT_TAIL(list, link) do { \
|
||||
(link)->next = (list); \
|
||||
(link)->prev = (list)->prev; \
|
||||
(list)->prev->next = (link); \
|
||||
(list)->prev = (link); \
|
||||
} while (0)
|
||||
#else
|
||||
#define DWC_LIST_INSERT_HEAD(list, link) do { \
|
||||
dwc_list_link_t *__next__ = (list)->next; \
|
||||
__next__->prev = (link); \
|
||||
(link)->next = __next__; \
|
||||
(link)->prev = (list); \
|
||||
(list)->next = (link); \
|
||||
} while (0)
|
||||
|
||||
#define DWC_LIST_INSERT_TAIL(list, link) do { \
|
||||
dwc_list_link_t *__prev__ = (list)->prev; \
|
||||
(list)->prev = (link); \
|
||||
(link)->next = (list); \
|
||||
(link)->prev = __prev__; \
|
||||
__prev__->next = (link); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static inline void __list_add(struct list_head *new,
|
||||
struct list_head *prev,
|
||||
struct list_head *next)
|
||||
{
|
||||
next->prev = new;
|
||||
new->next = next;
|
||||
new->prev = prev;
|
||||
prev->next = new;
|
||||
}
|
||||
|
||||
static inline void list_add(struct list_head *new, struct list_head *head)
|
||||
{
|
||||
__list_add(new, head, head->next);
|
||||
}
|
||||
|
||||
static inline void list_add_tail(struct list_head *new, struct list_head *head)
|
||||
{
|
||||
__list_add(new, head->prev, head);
|
||||
}
|
||||
|
||||
static inline void __list_del(struct list_head * prev, struct list_head * next)
|
||||
{
|
||||
next->prev = prev;
|
||||
prev->next = next;
|
||||
}
|
||||
|
||||
static inline void list_del(struct list_head *entry)
|
||||
{
|
||||
__list_del(entry->prev, entry->next);
|
||||
entry->next = LIST_POISON1;
|
||||
entry->prev = LIST_POISON2;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define DWC_LIST_REMOVE(link) do { \
|
||||
(link)->next->prev = (link)->prev; \
|
||||
(link)->prev->next = (link)->next; \
|
||||
} while (0)
|
||||
|
||||
#define DWC_LIST_REMOVE_INIT(link) do { \
|
||||
DWC_LIST_REMOVE(link); \
|
||||
DWC_LIST_INIT(link); \
|
||||
} while (0)
|
||||
|
||||
#define DWC_LIST_MOVE_HEAD(list, link) do { \
|
||||
DWC_LIST_REMOVE(link); \
|
||||
DWC_LIST_INSERT_HEAD(list, link); \
|
||||
} while (0)
|
||||
|
||||
#define DWC_LIST_MOVE_TAIL(list, link) do { \
|
||||
DWC_LIST_REMOVE(link); \
|
||||
DWC_LIST_INSERT_TAIL(list, link); \
|
||||
} while (0)
|
||||
|
||||
#define DWC_LIST_FOREACH(var, list) \
|
||||
for((var) = DWC_LIST_FIRST(list); \
|
||||
(var) != DWC_LIST_END(list); \
|
||||
(var) = DWC_LIST_NEXT(var))
|
||||
|
||||
#define DWC_LIST_FOREACH_SAFE(var, var2, list) \
|
||||
for((var) = DWC_LIST_FIRST(list), (var2) = DWC_LIST_NEXT(var); \
|
||||
(var) != DWC_LIST_END(list); \
|
||||
(var) = (var2), (var2) = DWC_LIST_NEXT(var2))
|
||||
|
||||
#define DWC_LIST_FOREACH_REVERSE(var, list) \
|
||||
for((var) = DWC_LIST_LAST(list); \
|
||||
(var) != DWC_LIST_END(list); \
|
||||
(var) = DWC_LIST_PREV(var))
|
||||
|
||||
/*
|
||||
* Singly-linked List definitions.
|
||||
*/
|
||||
#define DWC_SLIST_HEAD(name, type) \
|
||||
struct name { \
|
||||
struct type *slh_first; /* first element */ \
|
||||
}
|
||||
|
||||
#define DWC_SLIST_HEAD_INITIALIZER(head) \
|
||||
{ NULL }
|
||||
|
||||
#define DWC_SLIST_ENTRY(type) \
|
||||
struct { \
|
||||
struct type *sle_next; /* next element */ \
|
||||
}
|
||||
|
||||
/*
|
||||
* Singly-linked List access methods.
|
||||
*/
|
||||
#define DWC_SLIST_FIRST(head) ((head)->slh_first)
|
||||
#define DWC_SLIST_END(head) NULL
|
||||
#define DWC_SLIST_EMPTY(head) (SLIST_FIRST(head) == SLIST_END(head))
|
||||
#define DWC_SLIST_NEXT(elm, field) ((elm)->field.sle_next)
|
||||
|
||||
#define DWC_SLIST_FOREACH(var, head, field) \
|
||||
for((var) = SLIST_FIRST(head); \
|
||||
(var) != SLIST_END(head); \
|
||||
(var) = SLIST_NEXT(var, field))
|
||||
|
||||
#define DWC_SLIST_FOREACH_PREVPTR(var, varp, head, field) \
|
||||
for((varp) = &SLIST_FIRST((head)); \
|
||||
((var) = *(varp)) != SLIST_END(head); \
|
||||
(varp) = &SLIST_NEXT((var), field))
|
||||
|
||||
/*
|
||||
* Singly-linked List functions.
|
||||
*/
|
||||
#define DWC_SLIST_INIT(head) { \
|
||||
SLIST_FIRST(head) = SLIST_END(head); \
|
||||
}
|
||||
|
||||
#define DWC_SLIST_INSERT_AFTER(slistelm, elm, field) do { \
|
||||
(elm)->field.sle_next = (slistelm)->field.sle_next; \
|
||||
(slistelm)->field.sle_next = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define DWC_SLIST_INSERT_HEAD(head, elm, field) do { \
|
||||
(elm)->field.sle_next = (head)->slh_first; \
|
||||
(head)->slh_first = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define DWC_SLIST_REMOVE_NEXT(head, elm, field) do { \
|
||||
(elm)->field.sle_next = (elm)->field.sle_next->field.sle_next; \
|
||||
} while (0)
|
||||
|
||||
#define DWC_SLIST_REMOVE_HEAD(head, field) do { \
|
||||
(head)->slh_first = (head)->slh_first->field.sle_next; \
|
||||
} while (0)
|
||||
|
||||
#define DWC_SLIST_REMOVE(head, elm, type, field) do { \
|
||||
if ((head)->slh_first == (elm)) { \
|
||||
SLIST_REMOVE_HEAD((head), field); \
|
||||
} \
|
||||
else { \
|
||||
struct type *curelm = (head)->slh_first; \
|
||||
while( curelm->field.sle_next != (elm) ) \
|
||||
curelm = curelm->field.sle_next; \
|
||||
curelm->field.sle_next = \
|
||||
curelm->field.sle_next->field.sle_next; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Simple queue definitions.
|
||||
*/
|
||||
#define DWC_SIMPLEQ_HEAD(name, type) \
|
||||
struct name { \
|
||||
struct type *sqh_first; /* first element */ \
|
||||
struct type **sqh_last; /* addr of last next element */ \
|
||||
}
|
||||
|
||||
#define DWC_SIMPLEQ_HEAD_INITIALIZER(head) \
|
||||
{ NULL, &(head).sqh_first }
|
||||
|
||||
#define DWC_SIMPLEQ_ENTRY(type) \
|
||||
struct { \
|
||||
struct type *sqe_next; /* next element */ \
|
||||
}
|
||||
|
||||
/*
|
||||
* Simple queue access methods.
|
||||
*/
|
||||
#define DWC_SIMPLEQ_FIRST(head) ((head)->sqh_first)
|
||||
#define DWC_SIMPLEQ_END(head) NULL
|
||||
#define DWC_SIMPLEQ_EMPTY(head) (SIMPLEQ_FIRST(head) == SIMPLEQ_END(head))
|
||||
#define DWC_SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next)
|
||||
|
||||
#define DWC_SIMPLEQ_FOREACH(var, head, field) \
|
||||
for((var) = SIMPLEQ_FIRST(head); \
|
||||
(var) != SIMPLEQ_END(head); \
|
||||
(var) = SIMPLEQ_NEXT(var, field))
|
||||
|
||||
/*
|
||||
* Simple queue functions.
|
||||
*/
|
||||
#define DWC_SIMPLEQ_INIT(head) do { \
|
||||
(head)->sqh_first = NULL; \
|
||||
(head)->sqh_last = &(head)->sqh_first; \
|
||||
} while (0)
|
||||
|
||||
#define DWC_SIMPLEQ_INSERT_HEAD(head, elm, field) do { \
|
||||
if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \
|
||||
(head)->sqh_last = &(elm)->field.sqe_next; \
|
||||
(head)->sqh_first = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define DWC_SIMPLEQ_INSERT_TAIL(head, elm, field) do { \
|
||||
(elm)->field.sqe_next = NULL; \
|
||||
*(head)->sqh_last = (elm); \
|
||||
(head)->sqh_last = &(elm)->field.sqe_next; \
|
||||
} while (0)
|
||||
|
||||
#define DWC_SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
|
||||
if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
|
||||
(head)->sqh_last = &(elm)->field.sqe_next; \
|
||||
(listelm)->field.sqe_next = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define DWC_SIMPLEQ_REMOVE_HEAD(head, field) do { \
|
||||
if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
|
||||
(head)->sqh_last = &(head)->sqh_first; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Tail queue definitions.
|
||||
*/
|
||||
#define DWC_TAILQ_HEAD(name, type) \
|
||||
struct name { \
|
||||
struct type *tqh_first; /* first element */ \
|
||||
struct type **tqh_last; /* addr of last next element */ \
|
||||
}
|
||||
|
||||
#define DWC_TAILQ_HEAD_INITIALIZER(head) \
|
||||
{ NULL, &(head).tqh_first }
|
||||
|
||||
#define DWC_TAILQ_ENTRY(type) \
|
||||
struct { \
|
||||
struct type *tqe_next; /* next element */ \
|
||||
struct type **tqe_prev; /* address of previous next element */ \
|
||||
}
|
||||
|
||||
/*
|
||||
* tail queue access methods
|
||||
*/
|
||||
#define DWC_TAILQ_FIRST(head) ((head)->tqh_first)
|
||||
#define DWC_TAILQ_END(head) NULL
|
||||
#define DWC_TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
|
||||
#define DWC_TAILQ_LAST(head, headname) \
|
||||
(*(((struct headname *)((head)->tqh_last))->tqh_last))
|
||||
/* XXX */
|
||||
#define DWC_TAILQ_PREV(elm, headname, field) \
|
||||
(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
|
||||
#define DWC_TAILQ_EMPTY(head) \
|
||||
(TAILQ_FIRST(head) == TAILQ_END(head))
|
||||
|
||||
#define DWC_TAILQ_FOREACH(var, head, field) \
|
||||
for((var) = TAILQ_FIRST(head); \
|
||||
(var) != TAILQ_END(head); \
|
||||
(var) = TAILQ_NEXT(var, field))
|
||||
|
||||
#define DWC_TAILQ_FOREACH_REVERSE(var, head, headname, field) \
|
||||
for((var) = TAILQ_LAST(head, headname); \
|
||||
(var) != TAILQ_END(head); \
|
||||
(var) = TAILQ_PREV(var, headname, field))
|
||||
|
||||
/*
|
||||
* Tail queue functions.
|
||||
*/
|
||||
#define DWC_TAILQ_INIT(head) do { \
|
||||
(head)->tqh_first = NULL; \
|
||||
(head)->tqh_last = &(head)->tqh_first; \
|
||||
} while (0)
|
||||
|
||||
#define DWC_TAILQ_INSERT_HEAD(head, elm, field) do { \
|
||||
if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
|
||||
(head)->tqh_first->field.tqe_prev = \
|
||||
&(elm)->field.tqe_next; \
|
||||
else \
|
||||
(head)->tqh_last = &(elm)->field.tqe_next; \
|
||||
(head)->tqh_first = (elm); \
|
||||
(elm)->field.tqe_prev = &(head)->tqh_first; \
|
||||
} while (0)
|
||||
|
||||
#define DWC_TAILQ_INSERT_TAIL(head, elm, field) do { \
|
||||
(elm)->field.tqe_next = NULL; \
|
||||
(elm)->field.tqe_prev = (head)->tqh_last; \
|
||||
*(head)->tqh_last = (elm); \
|
||||
(head)->tqh_last = &(elm)->field.tqe_next; \
|
||||
} while (0)
|
||||
|
||||
#define DWC_TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
|
||||
if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
|
||||
(elm)->field.tqe_next->field.tqe_prev = \
|
||||
&(elm)->field.tqe_next; \
|
||||
else \
|
||||
(head)->tqh_last = &(elm)->field.tqe_next; \
|
||||
(listelm)->field.tqe_next = (elm); \
|
||||
(elm)->field.tqe_prev = &(listelm)->field.tqe_next; \
|
||||
} while (0)
|
||||
|
||||
#define DWC_TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
|
||||
(elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
|
||||
(elm)->field.tqe_next = (listelm); \
|
||||
*(listelm)->field.tqe_prev = (elm); \
|
||||
(listelm)->field.tqe_prev = &(elm)->field.tqe_next; \
|
||||
} while (0)
|
||||
|
||||
#define DWC_TAILQ_REMOVE(head, elm, field) do { \
|
||||
if (((elm)->field.tqe_next) != NULL) \
|
||||
(elm)->field.tqe_next->field.tqe_prev = \
|
||||
(elm)->field.tqe_prev; \
|
||||
else \
|
||||
(head)->tqh_last = (elm)->field.tqe_prev; \
|
||||
*(elm)->field.tqe_prev = (elm)->field.tqe_next; \
|
||||
} while (0)
|
||||
|
||||
#define DWC_TAILQ_REPLACE(head, elm, elm2, field) do { \
|
||||
if (((elm2)->field.tqe_next = (elm)->field.tqe_next) != NULL) \
|
||||
(elm2)->field.tqe_next->field.tqe_prev = \
|
||||
&(elm2)->field.tqe_next; \
|
||||
else \
|
||||
(head)->tqh_last = &(elm2)->field.tqe_next; \
|
||||
(elm2)->field.tqe_prev = (elm)->field.tqe_prev; \
|
||||
*(elm2)->field.tqe_prev = (elm2); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Circular queue definitions.
|
||||
*/
|
||||
#define DWC_CIRCLEQ_HEAD(name, type) \
|
||||
struct name { \
|
||||
struct type *cqh_first; /* first element */ \
|
||||
struct type *cqh_last; /* last element */ \
|
||||
}
|
||||
|
||||
#define DWC_CIRCLEQ_HEAD_INITIALIZER(head) \
|
||||
{ DWC_CIRCLEQ_END(&head), DWC_CIRCLEQ_END(&head) }
|
||||
|
||||
#define DWC_CIRCLEQ_ENTRY(type) \
|
||||
struct { \
|
||||
struct type *cqe_next; /* next element */ \
|
||||
struct type *cqe_prev; /* previous element */ \
|
||||
}
|
||||
|
||||
/*
|
||||
* Circular queue access methods
|
||||
*/
|
||||
#define DWC_CIRCLEQ_FIRST(head) ((head)->cqh_first)
|
||||
#define DWC_CIRCLEQ_LAST(head) ((head)->cqh_last)
|
||||
#define DWC_CIRCLEQ_END(head) ((void *)(head))
|
||||
#define DWC_CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next)
|
||||
#define DWC_CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev)
|
||||
#define DWC_CIRCLEQ_EMPTY(head) \
|
||||
(DWC_CIRCLEQ_FIRST(head) == DWC_CIRCLEQ_END(head))
|
||||
|
||||
#define DWC_CIRCLEQ_EMPTY_ENTRY(elm, field) (((elm)->field.cqe_next == NULL) && ((elm)->field.cqe_prev == NULL))
|
||||
|
||||
#define DWC_CIRCLEQ_FOREACH(var, head, field) \
|
||||
for((var) = DWC_CIRCLEQ_FIRST(head); \
|
||||
(var) != DWC_CIRCLEQ_END(head); \
|
||||
(var) = DWC_CIRCLEQ_NEXT(var, field))
|
||||
|
||||
#define DWC_CIRCLEQ_FOREACH_SAFE(var, var2, head, field) \
|
||||
for((var) = DWC_CIRCLEQ_FIRST(head), var2 = DWC_CIRCLEQ_NEXT(var, field); \
|
||||
(var) != DWC_CIRCLEQ_END(head); \
|
||||
(var) = var2, var2 = DWC_CIRCLEQ_NEXT(var, field))
|
||||
|
||||
#define DWC_CIRCLEQ_FOREACH_REVERSE(var, head, field) \
|
||||
for((var) = DWC_CIRCLEQ_LAST(head); \
|
||||
(var) != DWC_CIRCLEQ_END(head); \
|
||||
(var) = DWC_CIRCLEQ_PREV(var, field))
|
||||
|
||||
/*
|
||||
* Circular queue functions.
|
||||
*/
|
||||
#define DWC_CIRCLEQ_INIT(head) do { \
|
||||
(head)->cqh_first = DWC_CIRCLEQ_END(head); \
|
||||
(head)->cqh_last = DWC_CIRCLEQ_END(head); \
|
||||
} while (0)
|
||||
|
||||
#define DWC_CIRCLEQ_INIT_ENTRY(elm, field) do { \
|
||||
(elm)->field.cqe_next = NULL; \
|
||||
(elm)->field.cqe_prev = NULL; \
|
||||
} while (0)
|
||||
|
||||
#define DWC_CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
|
||||
(elm)->field.cqe_next = (listelm)->field.cqe_next; \
|
||||
(elm)->field.cqe_prev = (listelm); \
|
||||
if ((listelm)->field.cqe_next == DWC_CIRCLEQ_END(head)) \
|
||||
(head)->cqh_last = (elm); \
|
||||
else \
|
||||
(listelm)->field.cqe_next->field.cqe_prev = (elm); \
|
||||
(listelm)->field.cqe_next = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define DWC_CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \
|
||||
(elm)->field.cqe_next = (listelm); \
|
||||
(elm)->field.cqe_prev = (listelm)->field.cqe_prev; \
|
||||
if ((listelm)->field.cqe_prev == DWC_CIRCLEQ_END(head)) \
|
||||
(head)->cqh_first = (elm); \
|
||||
else \
|
||||
(listelm)->field.cqe_prev->field.cqe_next = (elm); \
|
||||
(listelm)->field.cqe_prev = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define DWC_CIRCLEQ_INSERT_HEAD(head, elm, field) do { \
|
||||
(elm)->field.cqe_next = (head)->cqh_first; \
|
||||
(elm)->field.cqe_prev = DWC_CIRCLEQ_END(head); \
|
||||
if ((head)->cqh_last == DWC_CIRCLEQ_END(head)) \
|
||||
(head)->cqh_last = (elm); \
|
||||
else \
|
||||
(head)->cqh_first->field.cqe_prev = (elm); \
|
||||
(head)->cqh_first = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define DWC_CIRCLEQ_INSERT_TAIL(head, elm, field) do { \
|
||||
(elm)->field.cqe_next = DWC_CIRCLEQ_END(head); \
|
||||
(elm)->field.cqe_prev = (head)->cqh_last; \
|
||||
if ((head)->cqh_first == DWC_CIRCLEQ_END(head)) \
|
||||
(head)->cqh_first = (elm); \
|
||||
else \
|
||||
(head)->cqh_last->field.cqe_next = (elm); \
|
||||
(head)->cqh_last = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define DWC_CIRCLEQ_REMOVE(head, elm, field) do { \
|
||||
if ((elm)->field.cqe_next == DWC_CIRCLEQ_END(head)) \
|
||||
(head)->cqh_last = (elm)->field.cqe_prev; \
|
||||
else \
|
||||
(elm)->field.cqe_next->field.cqe_prev = \
|
||||
(elm)->field.cqe_prev; \
|
||||
if ((elm)->field.cqe_prev == DWC_CIRCLEQ_END(head)) \
|
||||
(head)->cqh_first = (elm)->field.cqe_next; \
|
||||
else \
|
||||
(elm)->field.cqe_prev->field.cqe_next = \
|
||||
(elm)->field.cqe_next; \
|
||||
} while (0)
|
||||
|
||||
#define DWC_CIRCLEQ_REMOVE_INIT(head, elm, field) do { \
|
||||
DWC_CIRCLEQ_REMOVE(head, elm, field); \
|
||||
DWC_CIRCLEQ_INIT_ENTRY(elm, field); \
|
||||
} while (0)
|
||||
|
||||
#define DWC_CIRCLEQ_REPLACE(head, elm, elm2, field) do { \
|
||||
if (((elm2)->field.cqe_next = (elm)->field.cqe_next) == \
|
||||
DWC_CIRCLEQ_END(head)) \
|
||||
(head).cqh_last = (elm2); \
|
||||
else \
|
||||
(elm2)->field.cqe_next->field.cqe_prev = (elm2); \
|
||||
if (((elm2)->field.cqe_prev = (elm)->field.cqe_prev) == \
|
||||
DWC_CIRCLEQ_END(head)) \
|
||||
(head).cqh_first = (elm2); \
|
||||
else \
|
||||
(elm2)->field.cqe_prev->field.cqe_next = (elm2); \
|
||||
} while (0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _DWC_LIST_H_ */
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,82 @@
|
|||
/* ==========================================================================
|
||||
* $File: //dwh/usb_iip/dev/software/otg/linux/drivers/dwc_otg_adp.h $
|
||||
* $Revision: #8 $
|
||||
* $Date: 2013/04/09 $
|
||||
* $Change: 2201932 $
|
||||
*
|
||||
* Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
|
||||
* "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
|
||||
* otherwise expressly agreed to in writing between Synopsys and you.
|
||||
*
|
||||
* The Software IS NOT an item of Licensed Software or Licensed Product under
|
||||
* any End User Software License Agreement or Agreement for Licensed Product
|
||||
* with Synopsys or any supplement thereto. You are permitted to use and
|
||||
* redistribute this Software in source and binary forms, with or without
|
||||
* modification, provided that redistributions of source code must retain this
|
||||
* notice. You may not view, use, disclose, copy or distribute this file or
|
||||
* any information contained herein except pursuant to this license grant from
|
||||
* Synopsys. If you do not agree with this notice, including the disclaimer
|
||||
* below, then you are not authorized to use the Software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
* ========================================================================== */
|
||||
|
||||
#ifndef __DWC_OTG_ADP_H__
|
||||
#define __DWC_OTG_ADP_H__
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* This file contains the Attach Detect Protocol interfaces and defines
|
||||
* (functions) and structures for Linux.
|
||||
*
|
||||
*/
|
||||
|
||||
#define DWC_OTG_ADP_UNATTACHED 0
|
||||
#define DWC_OTG_ADP_ATTACHED 1
|
||||
#define DWC_OTG_ADP_UNKOWN 2
|
||||
#define HOST_RTIM_THRESHOLD 5
|
||||
#define DEVICE_RTIM_THRESHOLD 3
|
||||
|
||||
typedef struct dwc_otg_adp {
|
||||
uint32_t adp_started;
|
||||
uint32_t initial_probe;
|
||||
int32_t probe_timer_values[2];
|
||||
uint32_t probe_enabled;
|
||||
uint32_t sense_enabled;
|
||||
dwc_timer_t *sense_timer;
|
||||
uint32_t sense_timer_started;
|
||||
dwc_timer_t *vbuson_timer;
|
||||
uint32_t vbuson_timer_started;
|
||||
uint32_t attached;
|
||||
uint32_t probe_counter;
|
||||
uint32_t gpwrdn;
|
||||
} dwc_otg_adp_t;
|
||||
|
||||
/**
|
||||
* Attach Detect Protocol functions
|
||||
*/
|
||||
|
||||
extern void dwc_otg_adp_write_reg(dwc_otg_core_if_t * core_if, uint32_t value);
|
||||
extern uint32_t dwc_otg_adp_read_reg(dwc_otg_core_if_t * core_if);
|
||||
extern uint32_t dwc_otg_adp_probe_start(dwc_otg_core_if_t * core_if);
|
||||
extern uint32_t dwc_otg_adp_sense_start(dwc_otg_core_if_t * core_if);
|
||||
extern uint32_t dwc_otg_adp_probe_stop(dwc_otg_core_if_t * core_if);
|
||||
extern uint32_t dwc_otg_adp_sense_stop(dwc_otg_core_if_t * core_if);
|
||||
extern void dwc_otg_adp_start(dwc_otg_core_if_t * core_if, uint8_t is_host);
|
||||
extern void dwc_otg_adp_init(dwc_otg_core_if_t * core_if);
|
||||
extern void dwc_otg_adp_remove(dwc_otg_core_if_t * core_if);
|
||||
extern int32_t dwc_otg_adp_handle_intr(dwc_otg_core_if_t * core_if);
|
||||
extern int32_t dwc_otg_adp_handle_srp_intr(dwc_otg_core_if_t * core_if);
|
||||
|
||||
#endif //__DWC_OTG_ADP_H__
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
/* ==========================================================================
|
||||
* $File: //dwh/usb_iip/dev/software/otg/linux/drivers/dwc_otg_attr.h $
|
||||
* $Revision: #13 $
|
||||
* $Date: 2010/06/21 $
|
||||
* $Change: 1532021 $
|
||||
*
|
||||
* Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
|
||||
* "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
|
||||
* otherwise expressly agreed to in writing between Synopsys and you.
|
||||
*
|
||||
* The Software IS NOT an item of Licensed Software or Licensed Product under
|
||||
* any End User Software License Agreement or Agreement for Licensed Product
|
||||
* with Synopsys or any supplement thereto. You are permitted to use and
|
||||
* redistribute this Software in source and binary forms, with or without
|
||||
* modification, provided that redistributions of source code must retain this
|
||||
* notice. You may not view, use, disclose, copy or distribute this file or
|
||||
* any information contained herein except pursuant to this license grant from
|
||||
* Synopsys. If you do not agree with this notice, including the disclaimer
|
||||
* below, then you are not authorized to use the Software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
* ========================================================================== */
|
||||
|
||||
#if !defined(__DWC_OTG_ATTR_H__)
|
||||
#define __DWC_OTG_ATTR_H__
|
||||
#if 0
|
||||
/** @file
|
||||
* This file contains the interface to the Linux device attributes.
|
||||
*/
|
||||
extern struct device_attribute dev_attr_regoffset;
|
||||
extern struct device_attribute dev_attr_regvalue;
|
||||
|
||||
extern struct device_attribute dev_attr_mode;
|
||||
extern struct device_attribute dev_attr_hnpcapable;
|
||||
extern struct device_attribute dev_attr_srpcapable;
|
||||
extern struct device_attribute dev_attr_hnp;
|
||||
extern struct device_attribute dev_attr_srp;
|
||||
extern struct device_attribute dev_attr_buspower;
|
||||
extern struct device_attribute dev_attr_bussuspend;
|
||||
extern struct device_attribute dev_attr_mode_ch_tim_en;
|
||||
extern struct device_attribute dev_attr_fr_interval;
|
||||
extern struct device_attribute dev_attr_busconnected;
|
||||
extern struct device_attribute dev_attr_gotgctl;
|
||||
extern struct device_attribute dev_attr_gusbcfg;
|
||||
extern struct device_attribute dev_attr_grxfsiz;
|
||||
extern struct device_attribute dev_attr_gnptxfsiz;
|
||||
extern struct device_attribute dev_attr_gpvndctl;
|
||||
extern struct device_attribute dev_attr_ggpio;
|
||||
extern struct device_attribute dev_attr_guid;
|
||||
extern struct device_attribute dev_attr_gsnpsid;
|
||||
extern struct device_attribute dev_attr_devspeed;
|
||||
extern struct device_attribute dev_attr_enumspeed;
|
||||
extern struct device_attribute dev_attr_hptxfsiz;
|
||||
extern struct device_attribute dev_attr_hprt0;
|
||||
#ifdef CONFIG_USB_DWC_OTG_LPM
|
||||
extern struct device_attribute dev_attr_lpm_response;
|
||||
extern struct device_attribute devi_attr_sleep_status;
|
||||
#endif
|
||||
|
||||
void dwc_otg_attr_create(
|
||||
#ifdef LM_INTERFACE
|
||||
struct lm_device *dev
|
||||
#elif PCI_INTERFACE
|
||||
struct pci_dev *dev
|
||||
#endif
|
||||
);
|
||||
|
||||
void dwc_otg_attr_remove(
|
||||
#ifdef LM_INTERFACE
|
||||
struct lm_device *dev
|
||||
#elif PCI_INTERFACE
|
||||
struct pci_dev *dev
|
||||
#endif
|
||||
);
|
||||
#endif
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
#include "basic_types.h"
|
||||
#include <osdep_api.h>
|
||||
//#include "va_list.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "diag.h"
|
||||
#include "dwc_otg_dbg.h"
|
||||
#include "dwc_os.h"
|
||||
|
||||
|
||||
typedef struct _RAM_OTG_FUNCTION_TABLE_ {
|
||||
VOID* (*RamMemSet) (void *dest, int byte, SIZE_T size);
|
||||
VOID* (*RamMemCpy) (void *dest, void const *src, SIZE_T size);
|
||||
int (*RamMemCmp) (void const*m1, void const *m2, SIZE_T size);
|
||||
int (*RamStrnCmp) (const char *s1, const char *s2, SIZE_T size);
|
||||
int (*RamStrCmp) (const char *s1, const char *s2);
|
||||
SIZE_T (*RamStrLen) (char const *str);
|
||||
char* (*RamStrCpy) (char *to, char const *from);
|
||||
char* (*RamStrDup) (char const *str);
|
||||
int (*RamAtoi) (const char *str, int32_t *value);
|
||||
int (*RamAtoui) (const char *str, uint32_t *value);
|
||||
int (*RamVsnPrintf) (char *str, int size, const char *format, ...);
|
||||
u32 (*RamSPrintf) (u8 *buf, const char *fmt, ...);
|
||||
int (*RamSnPrintf) (char *dst, int count, const char * src, ...);
|
||||
u8* (*RamZmalloc) (u32 sz);
|
||||
u8* (*RamZmallocAtomic) (u32 sz);
|
||||
VOID (*RamMfree) (u8 *pbuf, u32 sz);
|
||||
dwc_spinlock_t* (*RamSpinlockAlloc) (void);
|
||||
VOID (*RamSpinlockFree) (dwc_spinlock_t *lock);
|
||||
VOID (*RamSpinlock) (dwc_spinlock_t *lock);
|
||||
VOID (*RamSpinUnlock) (dwc_spinlock_t *lock);
|
||||
VOID (*RamSpinIrqSave) (dwc_spinlock_t *lock, dwc_irqflags_t *flags);
|
||||
VOID (*RamSpinIrqRestore) (dwc_spinlock_t *lock, dwc_irqflags_t flags);
|
||||
dwc_mutex_t*(*RamMutexAlloc) (void);
|
||||
VOID (*RamMutexFree) (dwc_mutex_t *mutex);
|
||||
VOID (*RamMutexLock) (dwc_mutex_t *mutex);
|
||||
int (*RamMutexTryLock) (dwc_mutex_t *mutex);
|
||||
VOID (*RamMutexUnLock) (dwc_mutex_t *mutex);
|
||||
uint32_t(*RamUDelay) (uint32_t usecs);
|
||||
void (*RamMSleep) (uint32_t msecs);
|
||||
VOID (*timer_callback) (unsigned long data);
|
||||
dwc_timer_t *(*RamTimerAlloc) (char *name, dwc_timer_callback_t cb, void *data);
|
||||
VOID (*RamTimerFree) (dwc_timer_t *timer);
|
||||
VOID (*RamTimerSche) (dwc_timer_t *timer, uint32_t time_ms);
|
||||
VOID (*RamTimerCancel) (dwc_timer_t *timer);
|
||||
VOID (*RamEnterCritical) (void);
|
||||
VOID (*RamExitCritical) (void);
|
||||
}RAM_OTG_FUNCTION_TABLE, *PRAM_OTG_FUNCTION_TABLE;
|
||||
|
||||
|
||||
|
||||
// Global Variable
|
||||
extern RAM_OTG_FUNCTION_TABLE gRamOTGFunTbl;
|
||||
|
||||
// Funtion Prototype
|
||||
// ROM
|
||||
_LONG_CALL_ void dwc_otg_wrapper_reset(IN VOID);
|
||||
_LONG_CALL_ void dwc_otg_wrapper_init_boot(IN VOID);
|
||||
_LONG_CALL_ void dwc_otg_power_init(IN VOID);
|
||||
|
||||
_LONG_CALL_ VOID RtlInitListhead_Otg(IN _LIST *list);
|
||||
_LONG_CALL_ u32 RtlIsListEmpty_Otg(IN _LIST *phead);
|
||||
_LONG_CALL_ VOID RtlListInsertHead_Otg(IN _LIST *plist,IN _LIST *phead);
|
||||
_LONG_CALL_ VOID RtlListInsertTail_Otg(IN _LIST *plist,IN _LIST *phead);
|
||||
_LONG_CALL_ _LIST *RtlListGetNext_Otg(IN _LIST *plist);
|
||||
_LONG_CALL_ VOID RtlListDelete_Otg(IN _LIST *plist);
|
||||
|
||||
extern _LONG_CALL_ char *DWC_STRDUP_ROM(char const *str);
|
||||
extern _LONG_CALL_ int DWC_ATOI_ROM(const char *str, int32_t *value);
|
||||
extern _LONG_CALL_ int DWC_ATOUI_ROM(const char *str, uint32_t *value);
|
||||
// RAM
|
||||
extern void dwc_otg_wrapper_init(IN VOID);
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,746 @@
|
|||
/* ==========================================================================
|
||||
* $File: //dwh/usb_iip/dev/software/otg/linux/drivers/dwc_otg_core_if.h $
|
||||
* $Revision: #15 $
|
||||
* $Date: 2012/12/10 $
|
||||
* $Change: 2123206 $
|
||||
*
|
||||
* Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
|
||||
* "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
|
||||
* otherwise expressly agreed to in writing between Synopsys and you.
|
||||
*
|
||||
* The Software IS NOT an item of Licensed Software or Licensed Product under
|
||||
* any End User Software License Agreement or Agreement for Licensed Product
|
||||
* with Synopsys or any supplement thereto. You are permitted to use and
|
||||
* redistribute this Software in source and binary forms, with or without
|
||||
* modification, provided that redistributions of source code must retain this
|
||||
* notice. You may not view, use, disclose, copy or distribute this file or
|
||||
* any information contained herein except pursuant to this license grant from
|
||||
* Synopsys. If you do not agree with this notice, including the disclaimer
|
||||
* below, then you are not authorized to use the Software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
* ========================================================================== */
|
||||
#if !defined(__DWC_CORE_IF_H__)
|
||||
#define __DWC_CORE_IF_H__
|
||||
|
||||
#include "dwc_os.h"
|
||||
|
||||
/** @file
|
||||
* This file defines DWC_OTG Core API
|
||||
*/
|
||||
|
||||
struct dwc_otg_core_if;
|
||||
typedef struct dwc_otg_core_if dwc_otg_core_if_t;
|
||||
|
||||
/** Maximum number of Periodic FIFOs */
|
||||
#define MAX_PERIO_FIFOS 15
|
||||
/** Maximum number of Periodic FIFOs */
|
||||
#define MAX_TX_FIFOS 15
|
||||
|
||||
/** Maximum number of Endpoints/HostChannels */
|
||||
#define MAX_EPS_CHANNELS 8
|
||||
|
||||
extern _LONG_CALL_ dwc_otg_core_if_t *dwc_otg_cil_init(const uint32_t * _reg_base_addr, int mode);
|
||||
extern _LONG_CALL_ void dwc_otg_core_init(dwc_otg_core_if_t * _core_if);
|
||||
extern _LONG_CALL_ void dwc_otg_cil_remove(dwc_otg_core_if_t * _core_if);
|
||||
|
||||
extern _LONG_CALL_ void dwc_otg_enable_global_interrupts(dwc_otg_core_if_t * _core_if);
|
||||
extern _LONG_CALL_ void dwc_otg_disable_global_interrupts(dwc_otg_core_if_t * _core_if);
|
||||
|
||||
extern _LONG_CALL_ uint8_t dwc_otg_is_device_mode(dwc_otg_core_if_t * _core_if);
|
||||
extern _LONG_CALL_ uint8_t dwc_otg_is_host_mode(dwc_otg_core_if_t * _core_if);
|
||||
|
||||
extern _LONG_CALL_ uint8_t dwc_otg_is_dma_enable(dwc_otg_core_if_t * core_if);
|
||||
|
||||
/** This function should be called on every hardware interrupt. */
|
||||
extern _LONG_CALL_ int32_t dwc_otg_handle_common_intr(void *otg_dev);
|
||||
|
||||
/** @name OTG Core Parameters */
|
||||
/** @{ */
|
||||
|
||||
/**
|
||||
* Specifies the OTG capabilities. The driver will automatically
|
||||
* detect the value for this parameter if none is specified.
|
||||
* 0 - HNP and SRP capable (default)
|
||||
* 1 - SRP Only capable
|
||||
* 2 - No HNP/SRP capable
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_otg_cap(dwc_otg_core_if_t * core_if, int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_otg_cap(dwc_otg_core_if_t * core_if);
|
||||
#define DWC_OTG_CAP_PARAM_HNP_SRP_CAPABLE 0
|
||||
#define DWC_OTG_CAP_PARAM_SRP_ONLY_CAPABLE 1
|
||||
#define DWC_OTG_CAP_PARAM_NO_HNP_SRP_CAPABLE 2
|
||||
#define dwc_param_otg_cap_default DWC_OTG_CAP_PARAM_HNP_SRP_CAPABLE
|
||||
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_opt(dwc_otg_core_if_t * core_if, int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_opt(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_opt_default 1
|
||||
|
||||
/**
|
||||
* Specifies whether to use slave or DMA mode for accessing the data
|
||||
* FIFOs. The driver will automatically detect the value for this
|
||||
* parameter if none is specified.
|
||||
* 0 - Slave
|
||||
* 1 - DMA (default, if available)
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_dma_enable(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_dma_enable(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_dma_enable_default 1
|
||||
|
||||
/**
|
||||
* When DMA mode is enabled specifies whether to use
|
||||
* address DMA or DMA Descritor mode for accessing the data
|
||||
* FIFOs in device mode. The driver will automatically detect
|
||||
* the value for this parameter if none is specified.
|
||||
* 0 - address DMA
|
||||
* 1 - DMA Descriptor(default, if available)
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_dma_desc_enable(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_dma_desc_enable(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_dma_desc_enable_default 1
|
||||
|
||||
/** The DMA Burst size (applicable only for External DMA
|
||||
* Mode). 1, 4, 8 16, 32, 64, 128, 256 (default 32)
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_dma_burst_size(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_dma_burst_size(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_dma_burst_size_default 32
|
||||
|
||||
/**
|
||||
* Specifies the maximum speed of operation in host and device mode.
|
||||
* The actual speed depends on the speed of the attached device and
|
||||
* the value of phy_type. The actual speed depends on the speed of the
|
||||
* attached device.
|
||||
* 0 - High Speed (default)
|
||||
* 1 - Full Speed
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_speed(dwc_otg_core_if_t * core_if, int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_speed(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_speed_default 0
|
||||
#define DWC_SPEED_PARAM_HIGH 0
|
||||
#define DWC_SPEED_PARAM_FULL 1
|
||||
|
||||
/** Specifies whether low power mode is supported when attached
|
||||
* to a Full Speed or Low Speed device in host mode.
|
||||
* 0 - Don't support low power mode (default)
|
||||
* 1 - Support low power mode
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_host_support_fs_ls_low_power(dwc_otg_core_if_t *
|
||||
core_if, int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_host_support_fs_ls_low_power(dwc_otg_core_if_t
|
||||
* core_if);
|
||||
#define dwc_param_host_support_fs_ls_low_power_default 0
|
||||
|
||||
/** Specifies the PHY clock rate in low power mode when connected to a
|
||||
* Low Speed device in host mode. This parameter is applicable only if
|
||||
* HOST_SUPPORT_FS_LS_LOW_POWER is enabled. If PHY_TYPE is set to FS
|
||||
* then defaults to 6 MHZ otherwise 48 MHZ.
|
||||
*
|
||||
* 0 - 48 MHz
|
||||
* 1 - 6 MHz
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_host_ls_low_power_phy_clk(dwc_otg_core_if_t *
|
||||
core_if, int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_host_ls_low_power_phy_clk(dwc_otg_core_if_t *
|
||||
core_if);
|
||||
#define dwc_param_host_ls_low_power_phy_clk_default 0
|
||||
#define DWC_HOST_LS_LOW_POWER_PHY_CLK_PARAM_48MHZ 0
|
||||
#define DWC_HOST_LS_LOW_POWER_PHY_CLK_PARAM_6MHZ 1
|
||||
|
||||
/**
|
||||
* 0 - Use cC FIFO size parameters
|
||||
* 1 - Allow dynamic FIFO sizing (default)
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_enable_dynamic_fifo(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_enable_dynamic_fifo(dwc_otg_core_if_t *
|
||||
core_if);
|
||||
#define dwc_param_enable_dynamic_fifo_default 1
|
||||
|
||||
/** Total number of 4-byte words in the data FIFO memory. This
|
||||
* memory includes the Rx FIFO, non-periodic Tx FIFO, and periodic
|
||||
* Tx FIFOs.
|
||||
* 32 to 32768 (default 8192)
|
||||
* Note: The total FIFO memory depth in the FPGA configuration is 8192.
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_data_fifo_size(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_data_fifo_size(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_data_fifo_size_default 8192
|
||||
|
||||
/** Number of 4-byte words in the Rx FIFO in device mode when dynamic
|
||||
* FIFO sizing is enabled.
|
||||
* 16 to 32768 (default 1064)
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_dev_rx_fifo_size(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_dev_rx_fifo_size(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_dev_rx_fifo_size_default 1064
|
||||
|
||||
/** Number of 4-byte words in the non-periodic Tx FIFO in device mode
|
||||
* when dynamic FIFO sizing is enabled.
|
||||
* 16 to 32768 (default 1024)
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_dev_nperio_tx_fifo_size(dwc_otg_core_if_t *
|
||||
core_if, int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_dev_nperio_tx_fifo_size(dwc_otg_core_if_t *
|
||||
core_if);
|
||||
#define dwc_param_dev_nperio_tx_fifo_size_default 1024
|
||||
|
||||
/** Number of 4-byte words in each of the periodic Tx FIFOs in device
|
||||
* mode when dynamic FIFO sizing is enabled.
|
||||
* 4 to 768 (default 256)
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_dev_perio_tx_fifo_size(dwc_otg_core_if_t * core_if,
|
||||
int32_t val, int fifo_num);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_dev_perio_tx_fifo_size(dwc_otg_core_if_t *
|
||||
core_if, int fifo_num);
|
||||
#define dwc_param_dev_perio_tx_fifo_size_default 256
|
||||
|
||||
/** Number of 4-byte words in the Rx FIFO in host mode when dynamic
|
||||
* FIFO sizing is enabled.
|
||||
* 16 to 32768 (default 1024)
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_host_rx_fifo_size(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_host_rx_fifo_size(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_host_rx_fifo_size_default 1024
|
||||
|
||||
/** Number of 4-byte words in the non-periodic Tx FIFO in host mode
|
||||
* when Dynamic FIFO sizing is enabled in the core.
|
||||
* 16 to 32768 (default 1024)
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_host_nperio_tx_fifo_size(dwc_otg_core_if_t *
|
||||
core_if, int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_host_nperio_tx_fifo_size(dwc_otg_core_if_t *
|
||||
core_if);
|
||||
#define dwc_param_host_nperio_tx_fifo_size_default 1024
|
||||
|
||||
/** Number of 4-byte words in the host periodic Tx FIFO when dynamic
|
||||
* FIFO sizing is enabled.
|
||||
* 16 to 32768 (default 1024)
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_host_perio_tx_fifo_size(dwc_otg_core_if_t *
|
||||
core_if, int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_host_perio_tx_fifo_size(dwc_otg_core_if_t *
|
||||
core_if);
|
||||
#define dwc_param_host_perio_tx_fifo_size_default 1024
|
||||
|
||||
/** The maximum transfer size supported in bytes.
|
||||
* 2047 to 65,535 (default 65,535)
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_max_transfer_size(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_max_transfer_size(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_max_transfer_size_default 65535
|
||||
|
||||
/** The maximum number of packets in a transfer.
|
||||
* 15 to 511 (default 511)
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_max_packet_count(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_max_packet_count(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_max_packet_count_default 511
|
||||
|
||||
/** The number of host channel registers to use.
|
||||
* 1 to 16 (default 12)
|
||||
* Note: The FPGA configuration supports a maximum of 12 host channels.
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_host_channels(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_host_channels(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_host_channels_default 12
|
||||
|
||||
/** The number of endpoints in addition to EP0 available for device
|
||||
* mode operations.
|
||||
* 1 to 15 (default 6 IN and OUT)
|
||||
* Note: The FPGA configuration supports a maximum of 6 IN and OUT
|
||||
* endpoints in addition to EP0.
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_dev_endpoints(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_dev_endpoints(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_dev_endpoints_default 6
|
||||
|
||||
/**
|
||||
* Specifies the type of PHY interface to use. By default, the driver
|
||||
* will automatically detect the phy_type.
|
||||
*
|
||||
* 0 - Full Speed PHY
|
||||
* 1 - UTMI+ (default)
|
||||
* 2 - ULPI
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_phy_type(dwc_otg_core_if_t * core_if, int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_phy_type(dwc_otg_core_if_t * core_if);
|
||||
#define DWC_PHY_TYPE_PARAM_FS 0
|
||||
#define DWC_PHY_TYPE_PARAM_UTMI 1
|
||||
#define DWC_PHY_TYPE_PARAM_ULPI 2
|
||||
#define dwc_param_phy_type_default DWC_PHY_TYPE_PARAM_UTMI
|
||||
|
||||
/**
|
||||
* Specifies the UTMI+ Data Width. This parameter is
|
||||
* applicable for a PHY_TYPE of UTMI+ or ULPI. (For a ULPI
|
||||
* PHY_TYPE, this parameter indicates the data width between
|
||||
* the MAC and the ULPI Wrapper.) Also, this parameter is
|
||||
* applicable only if the OTG_HSPHY_WIDTH cC parameter was set
|
||||
* to "8 and 16 bits", meaning that the core has been
|
||||
* configured to work at either data path width.
|
||||
*
|
||||
* 8 or 16 bits (default 16)
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_phy_utmi_width(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_phy_utmi_width(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_phy_utmi_width_default 16
|
||||
|
||||
/**
|
||||
* Specifies whether the ULPI operates at double or single
|
||||
* data rate. This parameter is only applicable if PHY_TYPE is
|
||||
* ULPI.
|
||||
*
|
||||
* 0 - single data rate ULPI interface with 8 bit wide data
|
||||
* bus (default)
|
||||
* 1 - double data rate ULPI interface with 4 bit wide data
|
||||
* bus
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_phy_ulpi_ddr(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_phy_ulpi_ddr(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_phy_ulpi_ddr_default 0
|
||||
|
||||
/**
|
||||
* Specifies whether to use the internal or external supply to
|
||||
* drive the vbus with a ULPI phy.
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_phy_ulpi_ext_vbus(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_phy_ulpi_ext_vbus(dwc_otg_core_if_t * core_if);
|
||||
#define DWC_PHY_ULPI_INTERNAL_VBUS 0
|
||||
#define DWC_PHY_ULPI_EXTERNAL_VBUS 1
|
||||
#define dwc_param_phy_ulpi_ext_vbus_default DWC_PHY_ULPI_INTERNAL_VBUS
|
||||
|
||||
/**
|
||||
* Specifies whether to use the I2Cinterface for full speed PHY. This
|
||||
* parameter is only applicable if PHY_TYPE is FS.
|
||||
* 0 - No (default)
|
||||
* 1 - Yes
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_i2c_enable(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_i2c_enable(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_i2c_enable_default 0
|
||||
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_ulpi_fs_ls(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_ulpi_fs_ls(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_ulpi_fs_ls_default 0
|
||||
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_ts_dline(dwc_otg_core_if_t * core_if, int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_ts_dline(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_ts_dline_default 0
|
||||
|
||||
/**
|
||||
* Specifies whether dedicated transmit FIFOs are
|
||||
* enabled for non periodic IN endpoints in device mode
|
||||
* 0 - No
|
||||
* 1 - Yes
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_en_multiple_tx_fifo(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_en_multiple_tx_fifo(dwc_otg_core_if_t *
|
||||
core_if);
|
||||
#define dwc_param_en_multiple_tx_fifo_default 1
|
||||
|
||||
/** Number of 4-byte words in each of the Tx FIFOs in device
|
||||
* mode when dynamic FIFO sizing is enabled.
|
||||
* 4 to 768 (default 256)
|
||||
*/
|
||||
//extern int dwc_otg_set_param_dev_tx_fifo_size(dwc_otg_core_if_t * core_if,
|
||||
// int fifo_num, int32_t val);
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_dev_tx_fifo_size(dwc_otg_core_if_t * core_if, int32_t val,
|
||||
int fifo_num);
|
||||
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_dev_tx_fifo_size(dwc_otg_core_if_t * core_if,
|
||||
int fifo_num);
|
||||
#define dwc_param_dev_tx_fifo_size_default 256
|
||||
|
||||
/** Thresholding enable flag-
|
||||
* bit 0 - enable non-ISO Tx thresholding
|
||||
* bit 1 - enable ISO Tx thresholding
|
||||
* bit 2 - enable Rx thresholding
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_thr_ctl(dwc_otg_core_if_t * core_if, int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_thr_ctl(dwc_otg_core_if_t * core_if, int fifo_num);
|
||||
#define dwc_param_thr_ctl_default 0
|
||||
|
||||
/** Thresholding length for Tx
|
||||
* FIFOs in 32 bit DWORDs
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_tx_thr_length(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_tx_thr_length(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_tx_thr_length_default 64
|
||||
|
||||
/** Thresholding length for Rx
|
||||
* FIFOs in 32 bit DWORDs
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_rx_thr_length(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_rx_thr_length(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_rx_thr_length_default 64
|
||||
|
||||
/**
|
||||
* Specifies whether LPM (Link Power Management) support is enabled
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_lpm_enable(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_lpm_enable(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_lpm_enable_default 1
|
||||
|
||||
/**
|
||||
* Specifies whether LPM Errata (Link Power Management) support is enabled
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_besl_enable(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_besl_enable(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_besl_enable_default 0
|
||||
|
||||
/**
|
||||
* Specifies baseline_besl default value
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_baseline_besl(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_baseline_besl(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_baseline_besl_default 0
|
||||
|
||||
/**
|
||||
* Specifies deep_besl default value
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_deep_besl(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_deep_besl(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_deep_besl_default 15
|
||||
|
||||
/**
|
||||
* Specifies whether PTI enhancement is enabled
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_pti_enable(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_pti_enable(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_pti_enable_default 0
|
||||
|
||||
/**
|
||||
* Specifies whether MPI enhancement is enabled
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_mpi_enable(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_mpi_enable(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_mpi_enable_default 0
|
||||
|
||||
/**
|
||||
* Specifies whether ADP capability is enabled
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_adp_enable(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_adp_enable(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_adp_enable_default 0
|
||||
|
||||
/**
|
||||
* Specifies whether IC_USB capability is enabled
|
||||
*/
|
||||
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_ic_usb_cap(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_ic_usb_cap(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_ic_usb_cap_default 0
|
||||
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_ahb_thr_ratio(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_ahb_thr_ratio(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_ahb_thr_ratio_default 0
|
||||
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_power_down(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_power_down(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_power_down_default 0
|
||||
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_reload_ctl(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_reload_ctl(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_reload_ctl_default 0
|
||||
|
||||
extern int dwc_otg_set_param_dev_out_nak(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_dev_out_nak(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_dev_out_nak_default 0
|
||||
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_cont_on_bna(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_cont_on_bna(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_cont_on_bna_default 0
|
||||
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_ahb_single(dwc_otg_core_if_t * core_if,
|
||||
int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_ahb_single(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_ahb_single_default 0
|
||||
|
||||
extern _LONG_CALL_ int dwc_otg_set_param_otg_ver(dwc_otg_core_if_t * core_if, int32_t val);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_get_param_otg_ver(dwc_otg_core_if_t * core_if);
|
||||
#define dwc_param_otg_ver_default 0
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @name Access to registers and bit-fields */
|
||||
|
||||
/**
|
||||
* Dump core registers and SPRAM
|
||||
*/
|
||||
extern _LONG_CALL_ void dwc_otg_dump_dev_registers(dwc_otg_core_if_t * _core_if);
|
||||
extern _LONG_CALL_ void dwc_otg_dump_spram(dwc_otg_core_if_t * _core_if);
|
||||
extern _LONG_CALL_ void dwc_otg_dump_host_registers(dwc_otg_core_if_t * _core_if);
|
||||
extern _LONG_CALL_ void dwc_otg_dump_global_registers(dwc_otg_core_if_t * _core_if);
|
||||
|
||||
/**
|
||||
* Get host negotiation status.
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_get_hnpstatus(dwc_otg_core_if_t * core_if);
|
||||
|
||||
/**
|
||||
* Get srp status
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_get_srpstatus(dwc_otg_core_if_t * core_if);
|
||||
|
||||
/**
|
||||
* Set hnpreq bit in the GOTGCTL register.
|
||||
*/
|
||||
extern _LONG_CALL_ void dwc_otg_set_hnpreq(dwc_otg_core_if_t * core_if, uint32_t val);
|
||||
|
||||
/**
|
||||
* Get Content of SNPSID register.
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_get_gsnpsid(dwc_otg_core_if_t * core_if);
|
||||
|
||||
/**
|
||||
* Get current mode.
|
||||
* Returns 0 if in device mode, and 1 if in host mode.
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_get_mode(dwc_otg_core_if_t * core_if);
|
||||
|
||||
/**
|
||||
* Get value of hnpcapable field in the GUSBCFG register
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_get_hnpcapable(dwc_otg_core_if_t * core_if);
|
||||
/**
|
||||
* Set value of hnpcapable field in the GUSBCFG register
|
||||
*/
|
||||
extern _LONG_CALL_ void dwc_otg_set_hnpcapable(dwc_otg_core_if_t * core_if, uint32_t val);
|
||||
|
||||
/**
|
||||
* Get value of srpcapable field in the GUSBCFG register
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_get_srpcapable(dwc_otg_core_if_t * core_if);
|
||||
/**
|
||||
* Set value of srpcapable field in the GUSBCFG register
|
||||
*/
|
||||
extern _LONG_CALL_ void dwc_otg_set_srpcapable(dwc_otg_core_if_t * core_if, uint32_t val);
|
||||
|
||||
/**
|
||||
* Get value of devspeed field in the DCFG register
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_get_devspeed(dwc_otg_core_if_t * core_if);
|
||||
/**
|
||||
* Set value of devspeed field in the DCFG register
|
||||
*/
|
||||
extern void dwc_otg_set_devspeed(dwc_otg_core_if_t * core_if, uint32_t val);
|
||||
|
||||
/**
|
||||
* Get the value of busconnected field from the HPRT0 register
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_get_busconnected(dwc_otg_core_if_t * core_if);
|
||||
|
||||
/**
|
||||
* Gets the device enumeration Speed.
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_get_enumspeed(dwc_otg_core_if_t * core_if);
|
||||
|
||||
/**
|
||||
* Get value of prtpwr field from the HPRT0 register
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_get_prtpower(dwc_otg_core_if_t * core_if);
|
||||
|
||||
/**
|
||||
* Get value of flag indicating core state - hibernated or not
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_get_core_state(dwc_otg_core_if_t * core_if);
|
||||
|
||||
/**
|
||||
* Set value of prtpwr field from the HPRT0 register
|
||||
*/
|
||||
extern _LONG_CALL_ void dwc_otg_set_prtpower(dwc_otg_core_if_t * core_if, uint32_t val);
|
||||
|
||||
/**
|
||||
* Get value of prtsusp field from the HPRT0 regsiter
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_get_prtsuspend(dwc_otg_core_if_t * core_if);
|
||||
/**
|
||||
* Set value of prtpwr field from the HPRT0 register
|
||||
*/
|
||||
extern _LONG_CALL_ void dwc_otg_set_prtsuspend(dwc_otg_core_if_t * core_if, uint32_t val);
|
||||
|
||||
/**
|
||||
* Get value of ModeChTimEn field from the HCFG regsiter
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_get_mode_ch_tim(dwc_otg_core_if_t * core_if);
|
||||
/**
|
||||
* Set value of ModeChTimEn field from the HCFG regsiter
|
||||
*/
|
||||
extern _LONG_CALL_ void dwc_otg_set_mode_ch_tim(dwc_otg_core_if_t * core_if, uint32_t val);
|
||||
|
||||
/**
|
||||
* Get value of Fram Interval field from the HFIR regsiter
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_get_fr_interval(dwc_otg_core_if_t * core_if);
|
||||
/**
|
||||
* Set value of Frame Interval field from the HFIR regsiter
|
||||
*/
|
||||
extern _LONG_CALL_ void dwc_otg_set_fr_interval(dwc_otg_core_if_t * core_if, uint32_t val);
|
||||
|
||||
/**
|
||||
* Set value of prtres field from the HPRT0 register
|
||||
*FIXME Remove?
|
||||
*/
|
||||
extern _LONG_CALL_ void dwc_otg_set_prtresume(dwc_otg_core_if_t * core_if, uint32_t val);
|
||||
|
||||
/**
|
||||
* Get value of rmtwkupsig bit in DCTL register
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_get_remotewakesig(dwc_otg_core_if_t * core_if);
|
||||
|
||||
/**
|
||||
* Get value of besl_reject bit in DCTL register
|
||||
*/
|
||||
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_get_beslreject(dwc_otg_core_if_t * core_if);
|
||||
|
||||
/**
|
||||
* Set value of besl_reject bit in DCTL register
|
||||
*/
|
||||
|
||||
extern _LONG_CALL_ void dwc_otg_set_beslreject(dwc_otg_core_if_t * core_if, uint32_t val);
|
||||
|
||||
/**
|
||||
* Get value of prt_sleep_sts field from the GLPMCFG register
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_get_lpm_portsleepstatus(dwc_otg_core_if_t * core_if);
|
||||
|
||||
/**
|
||||
* Get value of rem_wkup_en field from the GLPMCFG register
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_get_lpm_remotewakeenabled(dwc_otg_core_if_t * core_if);
|
||||
|
||||
/**
|
||||
* Get value of appl_resp field from the GLPMCFG register
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_get_lpmresponse(dwc_otg_core_if_t * core_if);
|
||||
/**
|
||||
* Set value of appl_resp field from the GLPMCFG register
|
||||
*/
|
||||
extern _LONG_CALL_ void dwc_otg_set_lpmresponse(dwc_otg_core_if_t * core_if, uint32_t val);
|
||||
|
||||
/**
|
||||
* Get value of hsic_connect field from the GLPMCFG register
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_get_hsic_connect(dwc_otg_core_if_t * core_if);
|
||||
/**
|
||||
* Set value of hsic_connect field from the GLPMCFG register
|
||||
*/
|
||||
extern _LONG_CALL_ void dwc_otg_set_hsic_connect(dwc_otg_core_if_t * core_if, uint32_t val);
|
||||
|
||||
/**
|
||||
* Get value of inv_sel_hsic field from the GLPMCFG register.
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_get_inv_sel_hsic(dwc_otg_core_if_t * core_if);
|
||||
/**
|
||||
* Set value of inv_sel_hsic field from the GLPMFG register.
|
||||
*/
|
||||
extern _LONG_CALL_ void dwc_otg_set_inv_sel_hsic(dwc_otg_core_if_t * core_if, uint32_t val);
|
||||
/**
|
||||
* Set value of hird_thresh field from the GLPMFG register.
|
||||
*/
|
||||
extern _LONG_CALL_ void dwc_otg_set_hirdthresh(dwc_otg_core_if_t * core_if, uint32_t val);
|
||||
/**
|
||||
* Get value of hird_thresh field from the GLPMFG register.
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_get_hirdthresh(dwc_otg_core_if_t * core_if);
|
||||
|
||||
|
||||
/*
|
||||
* Some functions for accessing registers
|
||||
*/
|
||||
|
||||
/**
|
||||
* GOTGCTL register
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_get_gotgctl(dwc_otg_core_if_t * core_if);
|
||||
extern _LONG_CALL_ void dwc_otg_set_gotgctl(dwc_otg_core_if_t * core_if, uint32_t val);
|
||||
|
||||
/**
|
||||
* GUSBCFG register
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_get_gusbcfg(dwc_otg_core_if_t * core_if);
|
||||
extern _LONG_CALL_ void dwc_otg_set_gusbcfg(dwc_otg_core_if_t * core_if, uint32_t val);
|
||||
|
||||
/**
|
||||
* GRXFSIZ register
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_get_grxfsiz(dwc_otg_core_if_t * core_if);
|
||||
extern _LONG_CALL_ void dwc_otg_set_grxfsiz(dwc_otg_core_if_t * core_if, uint32_t val);
|
||||
|
||||
/**
|
||||
* GNPTXFSIZ register
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_get_gnptxfsiz(dwc_otg_core_if_t * core_if);
|
||||
extern _LONG_CALL_ void dwc_otg_set_gnptxfsiz(dwc_otg_core_if_t * core_if, uint32_t val);
|
||||
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_get_gpvndctl(dwc_otg_core_if_t * core_if);
|
||||
extern _LONG_CALL_ void dwc_otg_set_gpvndctl(dwc_otg_core_if_t * core_if, uint32_t val);
|
||||
|
||||
/**
|
||||
* GGPIO register
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_get_ggpio(dwc_otg_core_if_t * core_if);
|
||||
extern _LONG_CALL_ void dwc_otg_set_ggpio(dwc_otg_core_if_t * core_if, uint32_t val);
|
||||
|
||||
/**
|
||||
* GUID register
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_get_guid(dwc_otg_core_if_t * core_if);
|
||||
extern _LONG_CALL_ void dwc_otg_set_guid(dwc_otg_core_if_t * core_if, uint32_t val);
|
||||
|
||||
/**
|
||||
* HPRT0 register
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_get_hprt0(dwc_otg_core_if_t * core_if);
|
||||
extern _LONG_CALL_ void dwc_otg_set_hprt0(dwc_otg_core_if_t * core_if, uint32_t val);
|
||||
|
||||
/**
|
||||
* GHPTXFSIZE
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_get_hptxfsiz(dwc_otg_core_if_t * core_if);
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* __DWC_CORE_IF_H__ */
|
||||
|
|
@ -0,0 +1,114 @@
|
|||
/* ==========================================================================
|
||||
*
|
||||
* Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
|
||||
* "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
|
||||
* otherwise expressly agreed to in writing between Synopsys and you.
|
||||
*
|
||||
* The Software IS NOT an item of Licensed Software or Licensed Product under
|
||||
* any End User Software License Agreement or Agreement for Licensed Product
|
||||
* with Synopsys or any supplement thereto. You are permitted to use and
|
||||
* redistribute this Software in source and binary forms, with or without
|
||||
* modification, provided that redistributions of source code must retain this
|
||||
* notice. You may not view, use, disclose, copy or distribute this file or
|
||||
* any information contained herein except pursuant to this license grant from
|
||||
* Synopsys. If you do not agree with this notice, including the disclaimer
|
||||
* below, then you are not authorized to use the Software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
* ========================================================================== */
|
||||
|
||||
#ifndef __DWC_OTG_DBG_H__
|
||||
#define __DWC_OTG_DBG_H__
|
||||
#include "section_config.h"
|
||||
|
||||
//#define OTGDEBUG 1
|
||||
#define VERBOSE 1
|
||||
|
||||
/** @file
|
||||
* This file defines debug levels.
|
||||
* Debugging support vanishes in non-debug builds.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Debug Level bit-mask variable.
|
||||
*/
|
||||
extern uint32_t g_dbg_lvl;
|
||||
/**
|
||||
* Set the Debug Level variable.
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t SET_DEBUG_LEVEL(const uint32_t new);
|
||||
|
||||
/** When debug level has the DBG_CIL bit set, display CIL Debug messages. */
|
||||
#define DBG_CIL (0x2)
|
||||
/** When debug level has the DBG_CILV bit set, display CIL Verbose debug
|
||||
* messages */
|
||||
#define DBG_CILV (0x20)
|
||||
/** When debug level has the DBG_PCD bit set, display PCD (Device) debug
|
||||
* messages */
|
||||
#define DBG_PCD (0x4)
|
||||
/** When debug level has the DBG_PCDV set, display PCD (Device) Verbose debug
|
||||
* messages */
|
||||
#define DBG_PCDV (0x40)
|
||||
/** When debug level has the DBG_HCD bit set, display Host debug messages */
|
||||
#define DBG_HCD (0x8)
|
||||
/** When debug level has the DBG_HCDV bit set, display Verbose Host debug
|
||||
* messages */
|
||||
#define DBG_HCDV (0x80)
|
||||
/** When debug level has the DBG_HCD_URB bit set, display enqueued URBs in host
|
||||
* mode. */
|
||||
#define DBG_HCD_URB (0x800)
|
||||
|
||||
/** When debug level has any bit set, display debug messages */
|
||||
#define DBG_ANY (0xFF)
|
||||
|
||||
/** All debug messages off */
|
||||
#define DBG_OFF 0
|
||||
|
||||
/** Prefix string for DWC_DEBUG print macros. */
|
||||
#define USB_DWC "DWC_otg: "
|
||||
|
||||
/**
|
||||
* Print a debug message when the Global debug level variable contains
|
||||
* the bit defined in <code>lvl</code>.
|
||||
*
|
||||
* @param[in] lvl - Debug level, use one of the DBG_ constants above.
|
||||
* @param[in] x - like printf
|
||||
*
|
||||
* Example:<p>
|
||||
* <code>
|
||||
* DWC_DEBUGPL( DBG_ANY, "%s(%p)\n", __func__, _reg_base_addr);
|
||||
* </code>
|
||||
* <br>
|
||||
* results in:<br>
|
||||
* <code>
|
||||
* usb-DWC_otg: dwc_otg_cil_init(ca867000)
|
||||
* </code>
|
||||
*/
|
||||
#ifdef OTGDEBUG
|
||||
|
||||
//# define DWC_DEBUGPL(lvl, x...) do{ if ((lvl)&g_dbg_lvl)__DWC_DEBUG(USB_DWC x ); }while(0)
|
||||
# define DWC_DEBUGPL(lvl, x...) do{ if ((lvl)&g_dbg_lvl)DBG_8195A_OTG(x); }while(0)
|
||||
|
||||
# define DWC_DEBUGP(x...) DWC_DEBUGPL(DBG_ANY, x )
|
||||
|
||||
# define CHK_DEBUG_LEVEL(level) ((level) & g_dbg_lvl)
|
||||
|
||||
#else
|
||||
|
||||
# define DWC_DEBUGPL(lvl, x...) do{}while(0)
|
||||
# define DWC_DEBUGP(x...)
|
||||
|
||||
# define CHK_DEBUG_LEVEL(level) (0)
|
||||
|
||||
#endif /*DEBUG*/
|
||||
#endif
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
/* ==========================================================================
|
||||
* $File: //dwh/usb_iip/dev/software/otg/linux/drivers/dwc_otg_driver.h $
|
||||
* $Revision: #19 $
|
||||
* $Date: 2010/11/15 $
|
||||
* $Change: 1627671 $
|
||||
*
|
||||
* Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
|
||||
* "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
|
||||
* otherwise expressly agreed to in writing between Synopsys and you.
|
||||
*
|
||||
* The Software IS NOT an item of Licensed Software or Licensed Product under
|
||||
* any End User Software License Agreement or Agreement for Licensed Product
|
||||
* with Synopsys or any supplement thereto. You are permitted to use and
|
||||
* redistribute this Software in source and binary forms, with or without
|
||||
* modification, provided that redistributions of source code must retain this
|
||||
* notice. You may not view, use, disclose, copy or distribute this file or
|
||||
* any information contained herein except pursuant to this license grant from
|
||||
* Synopsys. If you do not agree with this notice, including the disclaimer
|
||||
* below, then you are not authorized to use the Software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
* ========================================================================== */
|
||||
|
||||
#ifndef __DWC_OTG_DRIVER_H__
|
||||
#define __DWC_OTG_DRIVER_H__
|
||||
|
||||
/** @file
|
||||
* This file contains the interface to the Linux driver.
|
||||
*/
|
||||
//#include "dwc_otg_os_dep.h"
|
||||
#include "dwc_otg_core_if.h"
|
||||
#include "osdep_service.h"
|
||||
|
||||
/* Type declarations */
|
||||
struct dwc_otg_pcd;
|
||||
struct dwc_otg_hcd;
|
||||
|
||||
/**
|
||||
* This structure is a wrapper that encapsulates the driver components used to
|
||||
* manage a single DWC_otg controller.
|
||||
*/
|
||||
typedef struct dwc_otg_device {
|
||||
/** Structure containing OS-dependent stuff. KEEP THIS STRUCT AT THE
|
||||
* VERY BEGINNING OF THE DEVICE STRUCT. OSes such as FreeBSD and NetBSD
|
||||
* require this. */
|
||||
//struct os_dependent os_dep;
|
||||
/** Base address returned from ioremap() */
|
||||
void *base;
|
||||
uint32_t reg_offset;
|
||||
/** Pointer to the core interface structure. */
|
||||
dwc_otg_core_if_t *core_if;
|
||||
|
||||
/** Pointer to the PCD structure. */
|
||||
struct dwc_otg_pcd *pcd;
|
||||
|
||||
/** Pointer to the HCD structure. */
|
||||
struct dwc_otg_hcd *hcd;
|
||||
|
||||
/** Flag to indicate whether the common IRQ handler is installed. */
|
||||
uint8_t common_irq_installed;
|
||||
|
||||
} dwc_otg_device_t;
|
||||
|
||||
/*We must clear S3C24XX_EINTPEND external interrupt register
|
||||
* because after clearing in this register trigerred IRQ from
|
||||
* H/W core in kernel interrupt can be occured again before OTG
|
||||
* handlers clear all IRQ sources of Core registers because of
|
||||
* timing latencies and Low Level IRQ Type.
|
||||
*/
|
||||
#ifdef CONFIG_MACH_IPMATE
|
||||
#define S3C2410X_CLEAR_EINTPEND() \
|
||||
do { \
|
||||
__raw_writel(1UL << 11,S3C24XX_EINTPEND); \
|
||||
} while (0)
|
||||
#else
|
||||
#define S3C2410X_CLEAR_EINTPEND() do { } while (0)
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct USB_OTG_DRV_ADP {
|
||||
dwc_otg_device_t *otgdev;
|
||||
IRQ_HANDLE *pIrqHnd;
|
||||
#if !TASK_SCHEDULER_DISABLED
|
||||
#if defined(DWC_WITH_WLAN_OSDEP)
|
||||
_sema Sema;
|
||||
#else
|
||||
_Sema Sema;
|
||||
#endif
|
||||
#else
|
||||
u32 Sema;
|
||||
#endif
|
||||
#if !TASK_SCHEDULER_DISABLED
|
||||
#if defined(DWC_WITH_WLAN_OSDEP)
|
||||
struct task_struct OTGTask;
|
||||
#else
|
||||
xTaskHandle OTGTask;
|
||||
#endif
|
||||
#else
|
||||
u32 OTGTask;
|
||||
#endif
|
||||
|
||||
}USB_OTG_DRV_ADP,*PUSB_OTG_DRV_ADP;
|
||||
|
||||
|
||||
|
||||
typedef struct _DWC_OTG_ADAPTER_ {
|
||||
u32 temp0;
|
||||
dwc_otg_device_t *otgdev;
|
||||
u8 TestItem;
|
||||
}DWC_OTG_ADAPTER, *PDWC_OTG_ADAPTER;
|
||||
void dwc_otg_disable_irq(IN VOID);
|
||||
void dwc_otg_enable_irq(IN VOID);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,743 @@
|
|||
/* ==========================================================================
|
||||
* $File: //dwh/usb_iip/dev/software/otg/linux/drivers/dwc_otg_hcd.h $
|
||||
* $Revision: #58 $
|
||||
* $Date: 2011/09/15 $
|
||||
* $Change: 1846647 $
|
||||
*
|
||||
* Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
|
||||
* "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
|
||||
* otherwise expressly agreed to in writing between Synopsys and you.
|
||||
*
|
||||
* The Software IS NOT an item of Licensed Software or Licensed Product under
|
||||
* any End User Software License Agreement or Agreement for Licensed Product
|
||||
* with Synopsys or any supplement thereto. You are permitted to use and
|
||||
* redistribute this Software in source and binary forms, with or without
|
||||
* modification, provided that redistributions of source code must retain this
|
||||
* notice. You may not view, use, disclose, copy or distribute this file or
|
||||
* any information contained herein except pursuant to this license grant from
|
||||
* Synopsys. If you do not agree with this notice, including the disclaimer
|
||||
* below, then you are not authorized to use the Software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
* ========================================================================== */
|
||||
#if 1//ndef DWC_DEVICE_ONLY
|
||||
#ifndef __DWC_HCD_H__
|
||||
#define __DWC_HCD_H__
|
||||
|
||||
//#include "dwc_otg_os_dep.h"
|
||||
#include "usb.h"
|
||||
#include "dwc_otg_hcd_if.h"
|
||||
#include "dwc_otg_core_if.h"
|
||||
#include "dwc_list.h"
|
||||
#include "dwc_otg_cil.h"
|
||||
#undef DWC_HS_ELECT_TST
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* This file contains the structures, constants, and interfaces for
|
||||
* the Host Contoller Driver (HCD).
|
||||
*
|
||||
* The Host Controller Driver (HCD) is responsible for translating requests
|
||||
* from the USB Driver into the appropriate actions on the DWC_otg controller.
|
||||
* It isolates the USBD from the specifics of the controller by providing an
|
||||
* API to the USBD.
|
||||
*/
|
||||
|
||||
struct dwc_otg_hcd_pipe_info {
|
||||
uint8_t dev_addr;
|
||||
uint8_t ep_num;
|
||||
uint8_t pipe_type;
|
||||
uint8_t pipe_dir;
|
||||
uint16_t mps;
|
||||
};
|
||||
|
||||
struct dwc_otg_hcd_iso_packet_desc {
|
||||
uint32_t offset;
|
||||
uint32_t length;
|
||||
uint32_t actual_length;
|
||||
uint32_t status;
|
||||
};
|
||||
|
||||
struct dwc_otg_qtd;
|
||||
|
||||
struct dwc_otg_hcd_urb {
|
||||
void *priv;
|
||||
struct dwc_otg_qtd *qtd;
|
||||
void *buf;
|
||||
dwc_dma_t dma;
|
||||
void *setup_packet;
|
||||
dwc_dma_t setup_dma;
|
||||
uint32_t length;
|
||||
uint32_t actual_length;
|
||||
uint32_t status;
|
||||
uint32_t error_count;
|
||||
uint32_t packet_count;
|
||||
uint32_t flags;
|
||||
uint16_t interval;
|
||||
struct dwc_otg_hcd_pipe_info pipe_info;
|
||||
struct dwc_otg_hcd_iso_packet_desc iso_descs[0];
|
||||
};
|
||||
|
||||
extern _LONG_CALL_
|
||||
uint8_t dwc_otg_hcd_get_ep_num(struct dwc_otg_hcd_pipe_info *pipe);
|
||||
|
||||
extern _LONG_CALL_
|
||||
uint8_t dwc_otg_hcd_get_pipe_type(struct dwc_otg_hcd_pipe_info
|
||||
*pipe);
|
||||
|
||||
extern _LONG_CALL_
|
||||
uint16_t dwc_otg_hcd_get_mps(struct dwc_otg_hcd_pipe_info *pipe);
|
||||
|
||||
extern _LONG_CALL_
|
||||
uint8_t dwc_otg_hcd_get_dev_addr(struct dwc_otg_hcd_pipe_info
|
||||
*pipe);
|
||||
|
||||
extern _LONG_CALL_
|
||||
uint8_t dwc_otg_hcd_is_pipe_isoc(struct dwc_otg_hcd_pipe_info
|
||||
*pipe);
|
||||
|
||||
extern _LONG_CALL_
|
||||
uint8_t dwc_otg_hcd_is_pipe_int(struct dwc_otg_hcd_pipe_info
|
||||
*pipe);
|
||||
|
||||
extern _LONG_CALL_
|
||||
uint8_t dwc_otg_hcd_is_pipe_bulk(struct dwc_otg_hcd_pipe_info
|
||||
*pipe);
|
||||
|
||||
extern _LONG_CALL_
|
||||
uint8_t dwc_otg_hcd_is_pipe_control(struct dwc_otg_hcd_pipe_info
|
||||
*pipe);
|
||||
|
||||
extern _LONG_CALL_
|
||||
uint8_t dwc_otg_hcd_is_pipe_in(struct dwc_otg_hcd_pipe_info *pipe);
|
||||
|
||||
extern _LONG_CALL_
|
||||
uint8_t dwc_otg_hcd_is_pipe_out(struct dwc_otg_hcd_pipe_info
|
||||
*pipe);
|
||||
|
||||
extern _LONG_CALL_
|
||||
void dwc_otg_hcd_fill_pipe(struct dwc_otg_hcd_pipe_info *pipe,
|
||||
uint8_t devaddr, uint8_t ep_num,
|
||||
uint8_t pipe_type, uint8_t pipe_dir,
|
||||
uint16_t mps);
|
||||
|
||||
/**
|
||||
* Phases for control transfers.
|
||||
*/
|
||||
typedef enum dwc_otg_control_phase {
|
||||
DWC_OTG_CONTROL_SETUP,
|
||||
DWC_OTG_CONTROL_DATA,
|
||||
DWC_OTG_CONTROL_STATUS
|
||||
} dwc_otg_control_phase_e;
|
||||
|
||||
/** Transaction types. */
|
||||
typedef enum dwc_otg_transaction_type {
|
||||
DWC_OTG_TRANSACTION_NONE,
|
||||
DWC_OTG_TRANSACTION_PERIODIC,
|
||||
DWC_OTG_TRANSACTION_NON_PERIODIC,
|
||||
DWC_OTG_TRANSACTION_ALL
|
||||
} dwc_otg_transaction_type_e;
|
||||
|
||||
struct dwc_otg_qh;
|
||||
|
||||
/**
|
||||
* A Queue Transfer Descriptor (QTD) holds the state of a bulk, control,
|
||||
* interrupt, or isochronous transfer. A single QTD is created for each URB
|
||||
* (of one of these types) submitted to the HCD. The transfer associated with
|
||||
* a QTD may require one or multiple transactions.
|
||||
*
|
||||
* A QTD is linked to a Queue Head, which is entered in either the
|
||||
* non-periodic or periodic schedule for execution. When a QTD is chosen for
|
||||
* execution, some or all of its transactions may be executed. After
|
||||
* execution, the state of the QTD is updated. The QTD may be retired if all
|
||||
* its transactions are complete or if an error occurred. Otherwise, it
|
||||
* remains in the schedule so more transactions can be executed later.
|
||||
*/
|
||||
typedef struct dwc_otg_qtd {
|
||||
/**
|
||||
* Determines the PID of the next data packet for the data phase of
|
||||
* control transfers. Ignored for other transfer types.<br>
|
||||
* One of the following values:
|
||||
* - DWC_OTG_HC_PID_DATA0
|
||||
* - DWC_OTG_HC_PID_DATA1
|
||||
*/
|
||||
uint8_t data_toggle;
|
||||
|
||||
/** Current phase for control transfers (Setup, Data, or Status). */
|
||||
dwc_otg_control_phase_e control_phase;
|
||||
|
||||
/** Keep track of the current split type
|
||||
* for FS/LS endpoints on a HS Hub */
|
||||
uint8_t complete_split;
|
||||
|
||||
/** How many bytes transferred during SSPLIT OUT */
|
||||
uint32_t ssplit_out_xfer_count;
|
||||
|
||||
/**
|
||||
* Holds the number of bus errors that have occurred for a transaction
|
||||
* within this transfer.
|
||||
*/
|
||||
uint8_t error_count;
|
||||
|
||||
/**
|
||||
* Index of the next frame descriptor for an isochronous transfer. A
|
||||
* frame descriptor describes the buffer position and length of the
|
||||
* data to be transferred in the next scheduled (micro)frame of an
|
||||
* isochronous transfer. It also holds status for that transaction.
|
||||
* The frame index starts at 0.
|
||||
*/
|
||||
uint16_t isoc_frame_index;
|
||||
|
||||
/** Position of the ISOC split on full/low speed */
|
||||
uint8_t isoc_split_pos;
|
||||
|
||||
/** Position of the ISOC split in the buffer for the current frame */
|
||||
uint16_t isoc_split_offset;
|
||||
|
||||
/** URB for this transfer */
|
||||
struct dwc_otg_hcd_urb *urb;
|
||||
|
||||
struct dwc_otg_qh *qh;
|
||||
|
||||
/** This list of QTDs */
|
||||
DWC_CIRCLEQ_ENTRY(dwc_otg_qtd) qtd_list_entry;
|
||||
|
||||
/** Indicates if this QTD is currently processed by HW. */
|
||||
uint8_t in_process;
|
||||
|
||||
/** Number of DMA descriptors for this QTD */
|
||||
uint8_t n_desc;
|
||||
|
||||
/**
|
||||
* Last activated frame(packet) index.
|
||||
* Used in Descriptor DMA mode only.
|
||||
*/
|
||||
uint16_t isoc_frame_index_last;
|
||||
|
||||
} dwc_otg_qtd_t;
|
||||
|
||||
DWC_CIRCLEQ_HEAD(dwc_otg_qtd_list, dwc_otg_qtd);
|
||||
|
||||
/**
|
||||
* A Queue Head (QH) holds the static characteristics of an endpoint and
|
||||
* maintains a list of transfers (QTDs) for that endpoint. A QH structure may
|
||||
* be entered in either the non-periodic or periodic schedule.
|
||||
*/
|
||||
typedef struct dwc_otg_qh {
|
||||
/**
|
||||
* Endpoint type.
|
||||
* One of the following values:
|
||||
* - UE_CONTROL
|
||||
* - UE_BULK
|
||||
* - UE_INTERRUPT
|
||||
* - UE_ISOCHRONOUS
|
||||
*/
|
||||
uint8_t ep_type;
|
||||
uint8_t ep_is_in;
|
||||
|
||||
/** wMaxPacketSize Field of Endpoint Descriptor. */
|
||||
uint16_t maxp;
|
||||
|
||||
/**
|
||||
* Device speed.
|
||||
* One of the following values:
|
||||
* - DWC_OTG_EP_SPEED_LOW
|
||||
* - DWC_OTG_EP_SPEED_FULL
|
||||
* - DWC_OTG_EP_SPEED_HIGH
|
||||
*/
|
||||
uint8_t dev_speed;
|
||||
|
||||
/**
|
||||
* Determines the PID of the next data packet for non-control
|
||||
* transfers. Ignored for control transfers.<br>
|
||||
* One of the following values:
|
||||
* - DWC_OTG_HC_PID_DATA0
|
||||
* - DWC_OTG_HC_PID_DATA1
|
||||
*/
|
||||
uint8_t data_toggle;
|
||||
|
||||
/** Ping state if 1. */
|
||||
uint8_t ping_state;
|
||||
|
||||
/**
|
||||
* List of QTDs for this QH.
|
||||
*/
|
||||
struct dwc_otg_qtd_list qtd_list;
|
||||
|
||||
/** Host channel currently processing transfers for this QH. */
|
||||
struct dwc_hc *channel;
|
||||
|
||||
/** Full/low speed endpoint on high-speed hub requires split. */
|
||||
uint8_t do_split;
|
||||
|
||||
/** @name Periodic schedule information */
|
||||
/** @{ */
|
||||
|
||||
/** Bandwidth in microseconds per (micro)frame. */
|
||||
uint16_t usecs;
|
||||
|
||||
/** Interval between transfers in (micro)frames. */
|
||||
uint16_t interval;
|
||||
|
||||
/**
|
||||
* (micro)frame to initialize a periodic transfer. The transfer
|
||||
* executes in the following (micro)frame.
|
||||
*/
|
||||
uint16_t sched_frame;
|
||||
|
||||
/** (micro)frame at which last start split was initialized. */
|
||||
uint16_t start_split_frame;
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* Used instead of original buffer if
|
||||
* it(physical address) is not dword-aligned.
|
||||
*/
|
||||
uint8_t *dw_align_buf;
|
||||
dwc_dma_t dw_align_buf_dma;
|
||||
|
||||
/** Entry for QH in either the periodic or non-periodic schedule. */
|
||||
dwc_list_link_t qh_list_entry;
|
||||
|
||||
/** @name Descriptor DMA support */
|
||||
/** @{ */
|
||||
|
||||
/** Descriptor List. */
|
||||
dwc_otg_host_dma_desc_t *desc_list;
|
||||
|
||||
/** Descriptor List physical address. */
|
||||
dwc_dma_t desc_list_dma;
|
||||
|
||||
/**
|
||||
* Xfer Bytes array.
|
||||
* Each element corresponds to a descriptor and indicates
|
||||
* original XferSize size value for the descriptor.
|
||||
*/
|
||||
uint32_t *n_bytes;
|
||||
|
||||
/** Actual number of transfer descriptors in a list. */
|
||||
uint16_t ntd;
|
||||
|
||||
/** First activated isochronous transfer descriptor index. */
|
||||
uint8_t td_first;
|
||||
/** Last activated isochronous transfer descriptor index. */
|
||||
uint8_t td_last;
|
||||
|
||||
/** @} */
|
||||
|
||||
} dwc_otg_qh_t;
|
||||
|
||||
DWC_CIRCLEQ_HEAD(hc_list, dwc_hc);
|
||||
|
||||
/**
|
||||
* This structure holds the state of the HCD, including the non-periodic and
|
||||
* periodic schedules.
|
||||
*/
|
||||
struct dwc_otg_hcd {
|
||||
/** The DWC otg device pointer */
|
||||
struct dwc_otg_device *otg_dev;
|
||||
/** DWC OTG Core Interface Layer */
|
||||
dwc_otg_core_if_t *core_if;
|
||||
|
||||
/** Function HCD driver callbacks */
|
||||
struct dwc_otg_hcd_function_ops *fops;
|
||||
|
||||
/** Internal DWC HCD Flags */
|
||||
volatile union dwc_otg_hcd_internal_flags {
|
||||
uint32_t d32;
|
||||
struct {
|
||||
unsigned port_connect_status_change:1;
|
||||
unsigned port_connect_status:1;
|
||||
unsigned port_reset_change:1;
|
||||
unsigned port_enable_change:1;
|
||||
unsigned port_suspend_change:1;
|
||||
unsigned port_over_current_change:1;
|
||||
unsigned port_l1_change:1;
|
||||
unsigned reserved:26;
|
||||
} b;
|
||||
} flags;
|
||||
|
||||
/**
|
||||
* Inactive items in the non-periodic schedule. This is a list of
|
||||
* Queue Heads. Transfers associated with these Queue Heads are not
|
||||
* currently assigned to a host channel.
|
||||
*/
|
||||
dwc_list_link_t non_periodic_sched_inactive;
|
||||
|
||||
/**
|
||||
* Active items in the non-periodic schedule. This is a list of
|
||||
* Queue Heads. Transfers associated with these Queue Heads are
|
||||
* currently assigned to a host channel.
|
||||
*/
|
||||
dwc_list_link_t non_periodic_sched_active;
|
||||
|
||||
/**
|
||||
* Pointer to the next Queue Head to process in the active
|
||||
* non-periodic schedule.
|
||||
*/
|
||||
dwc_list_link_t *non_periodic_qh_ptr;
|
||||
|
||||
/**
|
||||
* Inactive items in the periodic schedule. This is a list of QHs for
|
||||
* periodic transfers that are _not_ scheduled for the next frame.
|
||||
* Each QH in the list has an interval counter that determines when it
|
||||
* needs to be scheduled for execution. This scheduling mechanism
|
||||
* allows only a simple calculation for periodic bandwidth used (i.e.
|
||||
* must assume that all periodic transfers may need to execute in the
|
||||
* same frame). However, it greatly simplifies scheduling and should
|
||||
* be sufficient for the vast majority of OTG hosts, which need to
|
||||
* connect to a small number of peripherals at one time.
|
||||
*
|
||||
* Items move from this list to periodic_sched_ready when the QH
|
||||
* interval counter is 0 at SOF.
|
||||
*/
|
||||
dwc_list_link_t periodic_sched_inactive;
|
||||
|
||||
/**
|
||||
* List of periodic QHs that are ready for execution in the next
|
||||
* frame, but have not yet been assigned to host channels.
|
||||
*
|
||||
* Items move from this list to periodic_sched_assigned as host
|
||||
* channels become available during the current frame.
|
||||
*/
|
||||
dwc_list_link_t periodic_sched_ready;
|
||||
|
||||
/**
|
||||
* List of periodic QHs to be executed in the next frame that are
|
||||
* assigned to host channels.
|
||||
*
|
||||
* Items move from this list to periodic_sched_queued as the
|
||||
* transactions for the QH are queued to the DWC_otg controller.
|
||||
*/
|
||||
dwc_list_link_t periodic_sched_assigned;
|
||||
|
||||
/**
|
||||
* List of periodic QHs that have been queued for execution.
|
||||
*
|
||||
* Items move from this list to either periodic_sched_inactive or
|
||||
* periodic_sched_ready when the channel associated with the transfer
|
||||
* is released. If the interval for the QH is 1, the item moves to
|
||||
* periodic_sched_ready because it must be rescheduled for the next
|
||||
* frame. Otherwise, the item moves to periodic_sched_inactive.
|
||||
*/
|
||||
dwc_list_link_t periodic_sched_queued;
|
||||
|
||||
/**
|
||||
* Total bandwidth claimed so far for periodic transfers. This value
|
||||
* is in microseconds per (micro)frame. The assumption is that all
|
||||
* periodic transfers may occur in the same (micro)frame.
|
||||
*/
|
||||
uint16_t periodic_usecs;
|
||||
|
||||
/**
|
||||
* Frame number read from the core at SOF. The value ranges from 0 to
|
||||
* DWC_HFNUM_MAX_FRNUM.
|
||||
*/
|
||||
uint16_t frame_number;
|
||||
|
||||
/**
|
||||
* Count of periodic QHs, if using several eps. For SOF enable/disable.
|
||||
*/
|
||||
uint16_t periodic_qh_count;
|
||||
|
||||
/**
|
||||
* Free host channels in the controller. This is a list of
|
||||
* dwc_hc_t items.
|
||||
*/
|
||||
struct hc_list free_hc_list;
|
||||
/**
|
||||
* Number of host channels assigned to periodic transfers. Currently
|
||||
* assuming that there is a dedicated host channel for each periodic
|
||||
* transaction and at least one host channel available for
|
||||
* non-periodic transactions.
|
||||
*/
|
||||
int periodic_channels;
|
||||
|
||||
/**
|
||||
* Number of host channels assigned to non-periodic transfers.
|
||||
*/
|
||||
int non_periodic_channels;
|
||||
|
||||
/**
|
||||
* Array of pointers to the host channel descriptors. Allows accessing
|
||||
* a host channel descriptor given the host channel number. This is
|
||||
* useful in interrupt handlers.
|
||||
*/
|
||||
struct dwc_hc *hc_ptr_array[MAX_EPS_CHANNELS];
|
||||
|
||||
/**
|
||||
* Buffer to use for any data received during the status phase of a
|
||||
* control transfer. Normally no data is transferred during the status
|
||||
* phase. This buffer is used as a bit bucket.
|
||||
*/
|
||||
uint8_t *status_buf;
|
||||
|
||||
/**
|
||||
* DMA address for status_buf.
|
||||
*/
|
||||
dma_addr_t status_buf_dma;
|
||||
#define DWC_OTG_HCD_STATUS_BUF_SIZE 64
|
||||
|
||||
/**
|
||||
* Connection timer. An OTG host must display a message if the device
|
||||
* does not connect. Started when the VBus power is turned on via
|
||||
* sysfs attribute "buspower".
|
||||
*/
|
||||
dwc_timer_t *conn_timer;
|
||||
|
||||
/* Tasket to do a reset */
|
||||
//dwc_tasklet_t *reset_tasklet;
|
||||
|
||||
/* */
|
||||
dwc_spinlock_t *lock;
|
||||
|
||||
/**
|
||||
* Private data that could be used by OS wrapper.
|
||||
*/
|
||||
void *priv;
|
||||
|
||||
uint8_t otg_port;
|
||||
|
||||
/** Frame List */
|
||||
uint32_t *frame_list;
|
||||
|
||||
/** Frame List DMA address */
|
||||
dma_addr_t frame_list_dma;
|
||||
|
||||
#ifdef OTGDEBUG
|
||||
uint32_t frrem_samples;
|
||||
uint64_t frrem_accum;
|
||||
|
||||
uint32_t hfnum_7_samples_a;
|
||||
uint64_t hfnum_7_frrem_accum_a;
|
||||
uint32_t hfnum_0_samples_a;
|
||||
uint64_t hfnum_0_frrem_accum_a;
|
||||
uint32_t hfnum_other_samples_a;
|
||||
uint64_t hfnum_other_frrem_accum_a;
|
||||
|
||||
uint32_t hfnum_7_samples_b;
|
||||
uint64_t hfnum_7_frrem_accum_b;
|
||||
uint32_t hfnum_0_samples_b;
|
||||
uint64_t hfnum_0_frrem_accum_b;
|
||||
uint32_t hfnum_other_samples_b;
|
||||
uint64_t hfnum_other_frrem_accum_b;
|
||||
#endif
|
||||
};
|
||||
|
||||
/** @name Transaction Execution Functions */
|
||||
/** @{ */
|
||||
extern _LONG_CALL_ dwc_otg_transaction_type_e dwc_otg_hcd_select_transactions(dwc_otg_hcd_t
|
||||
* hcd);
|
||||
extern _LONG_CALL_ void dwc_otg_hcd_queue_transactions(dwc_otg_hcd_t * hcd,
|
||||
dwc_otg_transaction_type_e tr_type);
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @name Interrupt Handler Functions */
|
||||
/** @{ */
|
||||
extern _LONG_CALL_ int32_t dwc_otg_hcd_handle_intr(dwc_otg_hcd_t * dwc_otg_hcd);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_hcd_handle_sof_intr(dwc_otg_hcd_t * dwc_otg_hcd);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_hcd_handle_rx_status_q_level_intr(dwc_otg_hcd_t *
|
||||
dwc_otg_hcd);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_hcd_handle_np_tx_fifo_empty_intr(dwc_otg_hcd_t *
|
||||
dwc_otg_hcd);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_hcd_handle_perio_tx_fifo_empty_intr(dwc_otg_hcd_t *
|
||||
dwc_otg_hcd);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_hcd_handle_incomplete_periodic_intr(dwc_otg_hcd_t *
|
||||
dwc_otg_hcd);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_hcd_handle_port_intr(dwc_otg_hcd_t * dwc_otg_hcd);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_hcd_handle_conn_id_status_change_intr(dwc_otg_hcd_t *
|
||||
dwc_otg_hcd);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_hcd_handle_disconnect_intr(dwc_otg_hcd_t * dwc_otg_hcd);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_hcd_handle_hc_intr(dwc_otg_hcd_t * dwc_otg_hcd);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_hcd_handle_hc_n_intr(dwc_otg_hcd_t * dwc_otg_hcd,
|
||||
uint32_t num);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_hcd_handle_session_req_intr(dwc_otg_hcd_t * dwc_otg_hcd);
|
||||
extern _LONG_CALL_ int32_t dwc_otg_hcd_handle_wakeup_detected_intr(dwc_otg_hcd_t *
|
||||
dwc_otg_hcd);
|
||||
/** @} */
|
||||
|
||||
/** @name Schedule Queue Functions */
|
||||
/** @{ */
|
||||
|
||||
/* Implemented in dwc_otg_hcd_queue.c */
|
||||
extern _LONG_CALL_ dwc_otg_qh_t *dwc_otg_hcd_qh_create(dwc_otg_hcd_t * hcd,
|
||||
dwc_otg_hcd_urb_t * urb, int atomic_alloc);
|
||||
extern _LONG_CALL_ void dwc_otg_hcd_qh_free(dwc_otg_hcd_t * hcd, dwc_otg_qh_t * qh);
|
||||
extern _LONG_CALL_ int dwc_otg_hcd_qh_add(dwc_otg_hcd_t * hcd, dwc_otg_qh_t * qh);
|
||||
extern _LONG_CALL_ void dwc_otg_hcd_qh_remove(dwc_otg_hcd_t * hcd, dwc_otg_qh_t * qh);
|
||||
extern _LONG_CALL_ void dwc_otg_hcd_qh_deactivate(dwc_otg_hcd_t * hcd, dwc_otg_qh_t * qh,
|
||||
int sched_csplit);
|
||||
|
||||
/** Remove and free a QH */
|
||||
extern _LONG_CALL_
|
||||
void dwc_otg_hcd_qh_remove_and_free(dwc_otg_hcd_t * hcd,
|
||||
dwc_otg_qh_t * qh);
|
||||
|
||||
/** Allocates memory for a QH structure.
|
||||
* @return Returns the memory allocate or NULL on error. */
|
||||
extern _LONG_CALL_
|
||||
dwc_otg_qh_t *dwc_otg_hcd_qh_alloc(int atomic_alloc);
|
||||
|
||||
extern _LONG_CALL_ dwc_otg_qtd_t *dwc_otg_hcd_qtd_create(dwc_otg_hcd_urb_t * urb,
|
||||
int atomic_alloc);
|
||||
extern _LONG_CALL_ void dwc_otg_hcd_qtd_init(dwc_otg_qtd_t * qtd, dwc_otg_hcd_urb_t * urb);
|
||||
extern _LONG_CALL_ int dwc_otg_hcd_qtd_add(dwc_otg_qtd_t * qtd, dwc_otg_hcd_t * dwc_otg_hcd,
|
||||
dwc_otg_qh_t ** qh, int atomic_alloc);
|
||||
|
||||
/** Allocates memory for a QTD structure.
|
||||
* @return Returns the memory allocate or NULL on error. */
|
||||
extern _LONG_CALL_
|
||||
dwc_otg_qtd_t *dwc_otg_hcd_qtd_alloc(int atomic_alloc);
|
||||
|
||||
/** Frees the memory for a QTD structure. QTD should already be removed from
|
||||
* list.
|
||||
* @param qtd QTD to free.*/
|
||||
extern _LONG_CALL_
|
||||
void dwc_otg_hcd_qtd_free(dwc_otg_qtd_t * qtd);
|
||||
|
||||
/** Removes a QTD from list.
|
||||
* @param hcd HCD instance.
|
||||
* @param qtd QTD to remove from list.
|
||||
* @param qh QTD belongs to.
|
||||
*/
|
||||
extern _LONG_CALL_
|
||||
void dwc_otg_hcd_qtd_remove(dwc_otg_hcd_t * hcd,
|
||||
dwc_otg_qtd_t * qtd,
|
||||
dwc_otg_qh_t * qh);
|
||||
|
||||
/** Remove and free a QTD
|
||||
* Need to disable IRQ and hold hcd lock while calling this function out of
|
||||
* interrupt servicing chain */
|
||||
extern _LONG_CALL_
|
||||
void dwc_otg_hcd_qtd_remove_and_free(dwc_otg_hcd_t * hcd,
|
||||
dwc_otg_qtd_t * qtd,
|
||||
dwc_otg_qh_t * qh);
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @name Descriptor DMA Supporting Functions */
|
||||
/** @{ */
|
||||
|
||||
extern _LONG_CALL_ void dwc_otg_hcd_start_xfer_ddma(dwc_otg_hcd_t * hcd, dwc_otg_qh_t * qh);
|
||||
extern _LONG_CALL_ void dwc_otg_hcd_complete_xfer_ddma(dwc_otg_hcd_t * hcd,
|
||||
dwc_hc_t * hc,
|
||||
dwc_otg_hc_regs_t * hc_regs,
|
||||
dwc_otg_halt_status_e halt_status);
|
||||
|
||||
extern _LONG_CALL_ int dwc_otg_hcd_qh_init_ddma(dwc_otg_hcd_t * hcd, dwc_otg_qh_t * qh);
|
||||
extern _LONG_CALL_ void dwc_otg_hcd_qh_free_ddma(dwc_otg_hcd_t * hcd, dwc_otg_qh_t * qh);
|
||||
extern _LONG_CALL_ void reset_tasklet_func(void *data);
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @name Internal Functions */
|
||||
/** @{ */
|
||||
extern _LONG_CALL_ dwc_otg_qh_t *dwc_urb_to_qh(dwc_otg_hcd_urb_t * urb);
|
||||
/** @} */
|
||||
|
||||
#ifdef CONFIG_USB_DWC_OTG_LPM
|
||||
extern _LONG_CALL_ int dwc_otg_hcd_get_hc_for_lpm_tran(dwc_otg_hcd_t * hcd,
|
||||
uint8_t devaddr);
|
||||
extern _LONG_CALL_ void dwc_otg_hcd_free_hc_from_lpm(dwc_otg_hcd_t * hcd);
|
||||
#endif
|
||||
|
||||
/** Gets the QH that contains the list_head */
|
||||
#define dwc_list_to_qh(_list_head_ptr_) container_of(_list_head_ptr_, dwc_otg_qh_t, qh_list_entry)
|
||||
|
||||
/** Gets the QTD that contains the list_head */
|
||||
#define dwc_list_to_qtd(_list_head_ptr_) container_of(_list_head_ptr_, dwc_otg_qtd_t, qtd_list_entry)
|
||||
|
||||
/** Check if QH is non-periodic */
|
||||
#define dwc_qh_is_non_per(_qh_ptr_) ((_qh_ptr_->ep_type == UE_BULK) || \
|
||||
(_qh_ptr_->ep_type == UE_CONTROL))
|
||||
|
||||
/** High bandwidth multiplier as encoded in highspeed endpoint descriptors */
|
||||
#define dwc_hb_mult(wMaxPacketSize) (1 + (((wMaxPacketSize) >> 11) & 0x03))
|
||||
|
||||
/** Packet size for any kind of endpoint descriptor */
|
||||
#define dwc_max_packet(wMaxPacketSize) ((wMaxPacketSize) & 0x07ff)
|
||||
|
||||
/**
|
||||
* Returns true if _frame1 is less than or equal to _frame2. The comparison is
|
||||
* done modulo DWC_HFNUM_MAX_FRNUM. This accounts for the rollover of the
|
||||
* frame number when the max frame number is reached.
|
||||
*/
|
||||
extern _LONG_CALL_
|
||||
int dwc_frame_num_le(uint16_t frame1, uint16_t frame2);
|
||||
|
||||
/**
|
||||
* Returns true if _frame1 is greater than _frame2. The comparison is done
|
||||
* modulo DWC_HFNUM_MAX_FRNUM. This accounts for the rollover of the frame
|
||||
* number when the max frame number is reached.
|
||||
*/
|
||||
extern _LONG_CALL_
|
||||
int dwc_frame_num_gt(uint16_t frame1, uint16_t frame2);
|
||||
|
||||
/**
|
||||
* Increments _frame by the amount specified by _inc. The addition is done
|
||||
* modulo DWC_HFNUM_MAX_FRNUM. Returns the incremented value.
|
||||
*/
|
||||
extern _LONG_CALL_
|
||||
uint16_t dwc_frame_num_inc(uint16_t frame, uint16_t inc);
|
||||
|
||||
extern _LONG_CALL_
|
||||
uint16_t dwc_full_frame_num(uint16_t frame);
|
||||
|
||||
extern _LONG_CALL_
|
||||
uint16_t dwc_micro_frame_num(uint16_t frame);
|
||||
|
||||
extern _LONG_CALL_ void dwc_otg_hcd_save_data_toggle(dwc_hc_t * hc,
|
||||
dwc_otg_hc_regs_t * hc_regs,
|
||||
dwc_otg_qtd_t * qtd);
|
||||
|
||||
extern _LONG_CALL_ void dwc_hcd_data_init(void);
|
||||
#ifdef OTGDEBUG
|
||||
/**
|
||||
* Macro to sample the remaining PHY clocks left in the current frame. This
|
||||
* may be used during debugging to determine the average time it takes to
|
||||
* execute sections of code. There are two possible sample points, "a" and
|
||||
* "b", so the _letter argument must be one of these values.
|
||||
*
|
||||
* To dump the average sample times, read the "hcd_frrem" sysfs attribute. For
|
||||
* example, "cat /sys/devices/lm0/hcd_frrem".
|
||||
*/
|
||||
#define dwc_sample_frrem(_hcd, _qh, _letter) \
|
||||
{ \
|
||||
hfnum_data_t hfnum; \
|
||||
dwc_otg_qtd_t *qtd; \
|
||||
qtd = list_entry(_qh->qtd_list.next, dwc_otg_qtd_t, qtd_list_entry); \
|
||||
if (usb_pipeint(qtd->urb->pipe) && _qh->start_split_frame != 0 && !qtd->complete_split) { \
|
||||
hfnum.d32 = DWC_READ_REG32(&_hcd->core_if->host_if->host_global_regs->hfnum); \
|
||||
switch (hfnum.b.frnum & 0x7) { \
|
||||
case 7: \
|
||||
_hcd->hfnum_7_samples_##_letter++; \
|
||||
_hcd->hfnum_7_frrem_accum_##_letter += hfnum.b.frrem; \
|
||||
break; \
|
||||
case 0: \
|
||||
_hcd->hfnum_0_samples_##_letter++; \
|
||||
_hcd->hfnum_0_frrem_accum_##_letter += hfnum.b.frrem; \
|
||||
break; \
|
||||
default: \
|
||||
_hcd->hfnum_other_samples_##_letter++; \
|
||||
_hcd->hfnum_other_frrem_accum_##_letter += hfnum.b.frrem; \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
#define dwc_sample_frrem(_hcd, _qh, _letter)
|
||||
#endif
|
||||
#endif
|
||||
#endif /* DWC_DEVICE_ONLY */
|
||||
|
|
@ -0,0 +1,412 @@
|
|||
/* ==========================================================================
|
||||
* $File: //dwh/usb_iip/dev/software/otg/linux/drivers/dwc_otg_hcd_if.h $
|
||||
* $Revision: #12 $
|
||||
* $Date: 2011/10/26 $
|
||||
* $Change: 1873028 $
|
||||
*
|
||||
* Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
|
||||
* "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
|
||||
* otherwise expressly agreed to in writing between Synopsys and you.
|
||||
*
|
||||
* The Software IS NOT an item of Licensed Software or Licensed Product under
|
||||
* any End User Software License Agreement or Agreement for Licensed Product
|
||||
* with Synopsys or any supplement thereto. You are permitted to use and
|
||||
* redistribute this Software in source and binary forms, with or without
|
||||
* modification, provided that redistributions of source code must retain this
|
||||
* notice. You may not view, use, disclose, copy or distribute this file or
|
||||
* any information contained herein except pursuant to this license grant from
|
||||
* Synopsys. If you do not agree with this notice, including the disclaimer
|
||||
* below, then you are not authorized to use the Software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
* ========================================================================== */
|
||||
#if 1//ndef DWC_DEVICE_ONLY
|
||||
#ifndef __DWC_HCD_IF_H__
|
||||
#define __DWC_HCD_IF_H__
|
||||
|
||||
#include "dwc_otg_core_if.h"
|
||||
|
||||
/** @file
|
||||
* This file defines DWC_OTG HCD Core API.
|
||||
*/
|
||||
|
||||
struct dwc_otg_hcd;
|
||||
typedef struct dwc_otg_hcd dwc_otg_hcd_t;
|
||||
|
||||
struct dwc_otg_hcd_urb;
|
||||
typedef struct dwc_otg_hcd_urb dwc_otg_hcd_urb_t;
|
||||
|
||||
/** @name HCD Function Driver Callbacks */
|
||||
/** @{ */
|
||||
|
||||
/** This function is called whenever core switches to host mode. */
|
||||
typedef int (*dwc_otg_hcd_start_cb_t) (dwc_otg_hcd_t * hcd);
|
||||
|
||||
/** This function is called when device has been disconnected */
|
||||
typedef int (*dwc_otg_hcd_disconnect_cb_t) (dwc_otg_hcd_t * hcd);
|
||||
|
||||
/** Wrapper provides this function to HCD to core, so it can get hub information to which device is connected */
|
||||
typedef int (*dwc_otg_hcd_hub_info_from_urb_cb_t) (dwc_otg_hcd_t * hcd,
|
||||
void *urb_handle,
|
||||
uint32_t * hub_addr,
|
||||
uint32_t * port_addr);
|
||||
/** Via this function HCD core gets device speed */
|
||||
typedef int (*dwc_otg_hcd_speed_from_urb_cb_t) (dwc_otg_hcd_t * hcd,
|
||||
void *urb_handle);
|
||||
|
||||
/** This function is called when urb is completed */
|
||||
typedef int (*dwc_otg_hcd_complete_urb_cb_t) (dwc_otg_hcd_t * hcd,
|
||||
void *urb_handle,
|
||||
dwc_otg_hcd_urb_t * dwc_otg_urb,
|
||||
int32_t status);
|
||||
|
||||
/** Via this function HCD core gets b_hnp_enable parameter */
|
||||
typedef int (*dwc_otg_hcd_get_b_hnp_enable) (dwc_otg_hcd_t * hcd);
|
||||
|
||||
struct dwc_otg_hcd_function_ops {
|
||||
dwc_otg_hcd_start_cb_t start;
|
||||
dwc_otg_hcd_disconnect_cb_t disconnect;
|
||||
dwc_otg_hcd_hub_info_from_urb_cb_t hub_info;
|
||||
dwc_otg_hcd_speed_from_urb_cb_t speed;
|
||||
dwc_otg_hcd_complete_urb_cb_t complete;
|
||||
dwc_otg_hcd_get_b_hnp_enable get_b_hnp_enable;
|
||||
};
|
||||
/** @} */
|
||||
|
||||
/** @name HCD Core API */
|
||||
/** @{ */
|
||||
/** This function allocates dwc_otg_hcd structure and returns pointer on it. */
|
||||
extern _LONG_CALL_ dwc_otg_hcd_t *dwc_otg_hcd_alloc_hcd(void);
|
||||
|
||||
/** This function should be called to initiate HCD Core.
|
||||
*
|
||||
* @param hcd The HCD
|
||||
* @param core_if The DWC_OTG Core
|
||||
*
|
||||
* Returns -DWC_E_NO_MEMORY if no enough memory.
|
||||
* Returns 0 on success
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_hcd_init(dwc_otg_hcd_t * hcd, dwc_otg_core_if_t * core_if);
|
||||
|
||||
/** Frees HCD
|
||||
*
|
||||
* @param hcd The HCD
|
||||
*/
|
||||
extern _LONG_CALL_ void dwc_otg_hcd_remove(dwc_otg_hcd_t * hcd);
|
||||
|
||||
/** This function should be called on every hardware interrupt.
|
||||
*
|
||||
* @param dwc_otg_hcd The HCD
|
||||
*
|
||||
* Returns non zero if interrupt is handled
|
||||
* Return 0 if interrupt is not handled
|
||||
*/
|
||||
extern _LONG_CALL_ int32_t dwc_otg_hcd_handle_intr(dwc_otg_hcd_t * dwc_otg_hcd);
|
||||
|
||||
/**
|
||||
* Returns private data set by
|
||||
* dwc_otg_hcd_set_priv_data function.
|
||||
*
|
||||
* @param hcd The HCD
|
||||
*/
|
||||
extern _LONG_CALL_ void *dwc_otg_hcd_get_priv_data(dwc_otg_hcd_t * hcd);
|
||||
|
||||
/**
|
||||
* Set private data.
|
||||
*
|
||||
* @param hcd The HCD
|
||||
* @param priv_data pointer to be stored in private data
|
||||
*/
|
||||
extern _LONG_CALL_ void dwc_otg_hcd_set_priv_data(dwc_otg_hcd_t * hcd, void *priv_data);
|
||||
|
||||
/**
|
||||
* This function initializes the HCD Core.
|
||||
*
|
||||
* @param hcd The HCD
|
||||
* @param fops The Function Driver Operations data structure containing pointers to all callbacks.
|
||||
*
|
||||
* Returns -DWC_E_NO_DEVICE if Core is currently is in device mode.
|
||||
* Returns 0 on success
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_hcd_start(dwc_otg_hcd_t * hcd,
|
||||
struct dwc_otg_hcd_function_ops *fops);
|
||||
|
||||
/**
|
||||
* Halts the DWC_otg host mode operations in a clean manner. USB transfers are
|
||||
* stopped.
|
||||
*
|
||||
* @param hcd The HCD
|
||||
*/
|
||||
extern _LONG_CALL_ void dwc_otg_hcd_stop(dwc_otg_hcd_t * hcd);
|
||||
|
||||
/**
|
||||
* Handles hub class-specific requests.
|
||||
*
|
||||
* @param dwc_otg_hcd The HCD
|
||||
* @param typeReq Request Type
|
||||
* @param wValue wValue from control request
|
||||
* @param wIndex wIndex from control request
|
||||
* @param buf data buffer
|
||||
* @param wLength data buffer length
|
||||
*
|
||||
* Returns -DWC_E_INVALID if invalid argument is passed
|
||||
* Returns 0 on success
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_hcd_hub_control(dwc_otg_hcd_t * dwc_otg_hcd,
|
||||
uint16_t typeReq, uint16_t wValue,
|
||||
uint16_t wIndex, uint8_t * buf,
|
||||
uint16_t wLength);
|
||||
|
||||
/**
|
||||
* Returns otg port number.
|
||||
*
|
||||
* @param hcd The HCD
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_hcd_otg_port(dwc_otg_hcd_t * hcd);
|
||||
|
||||
/**
|
||||
* Returns OTG version - either 1.3 or 2.0.
|
||||
*
|
||||
* @param core_if The core_if structure pointer
|
||||
*/
|
||||
extern _LONG_CALL_ uint16_t dwc_otg_get_otg_version(dwc_otg_core_if_t * core_if);
|
||||
|
||||
/**
|
||||
* Returns 1 if currently core is acting as B host, and 0 otherwise.
|
||||
*
|
||||
* @param hcd The HCD
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_hcd_is_b_host(dwc_otg_hcd_t * hcd);
|
||||
|
||||
/**
|
||||
* Returns current frame number.
|
||||
*
|
||||
* @param hcd The HCD
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_hcd_get_frame_number(dwc_otg_hcd_t * hcd);
|
||||
|
||||
/**
|
||||
* Dumps hcd state.
|
||||
*
|
||||
* @param hcd The HCD
|
||||
*/
|
||||
extern _LONG_CALL_ void dwc_otg_hcd_dump_state(dwc_otg_hcd_t * hcd);
|
||||
|
||||
/**
|
||||
* Dump the average frame remaining at SOF. This can be used to
|
||||
* determine average interrupt latency. Frame remaining is also shown for
|
||||
* start transfer and two additional sample points.
|
||||
* Currently this function is not implemented.
|
||||
*
|
||||
* @param hcd The HCD
|
||||
*/
|
||||
extern _LONG_CALL_ void dwc_otg_hcd_dump_frrem(dwc_otg_hcd_t * hcd);
|
||||
|
||||
/**
|
||||
* Sends LPM transaction to the local device.
|
||||
*
|
||||
* @param hcd The HCD
|
||||
* @param devaddr Device Address
|
||||
* @param hird Host initiated resume duration
|
||||
* @param bRemoteWake Value of bRemoteWake field in LPM transaction
|
||||
*
|
||||
* Returns negative value if sending LPM transaction was not succeeded.
|
||||
* Returns 0 on success.
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_hcd_send_lpm(dwc_otg_hcd_t * hcd, uint8_t devaddr,
|
||||
uint8_t hird, uint8_t bRemoteWake);
|
||||
|
||||
/* URB interface */
|
||||
|
||||
/**
|
||||
* Allocates memory for dwc_otg_hcd_urb structure.
|
||||
* Allocated memory should be freed by call of DWC_FREE.
|
||||
*
|
||||
* @param hcd The HCD
|
||||
* @param iso_desc_count Count of ISOC descriptors
|
||||
* @param atomic_alloc Specefies whether to perform atomic allocation.
|
||||
*/
|
||||
extern _LONG_CALL_ dwc_otg_hcd_urb_t *dwc_otg_hcd_urb_alloc(dwc_otg_hcd_t * hcd,
|
||||
int iso_desc_count,
|
||||
int atomic_alloc);
|
||||
|
||||
/**
|
||||
* Set pipe information in URB.
|
||||
*
|
||||
* @param hcd_urb DWC_OTG URB
|
||||
* @param devaddr Device Address
|
||||
* @param ep_num Endpoint Number
|
||||
* @param ep_type Endpoint Type
|
||||
* @param ep_dir Endpoint Direction
|
||||
* @param mps Max Packet Size
|
||||
*/
|
||||
extern _LONG_CALL_ void dwc_otg_hcd_urb_set_pipeinfo(dwc_otg_hcd_urb_t * hcd_urb,
|
||||
uint8_t devaddr, uint8_t ep_num,
|
||||
uint8_t ep_type, uint8_t ep_dir,
|
||||
uint16_t mps);
|
||||
|
||||
/* Transfer flags */
|
||||
#define URB_GIVEBACK_ASAP 0x1
|
||||
#define URB_SEND_ZERO_PACKET 0x2
|
||||
|
||||
/**
|
||||
* Sets dwc_otg_hcd_urb parameters.
|
||||
*
|
||||
* @param urb DWC_OTG URB allocated by dwc_otg_hcd_urb_alloc function.
|
||||
* @param urb_handle Unique handle for request, this will be passed back
|
||||
* to function driver in completion callback.
|
||||
* @param buf The buffer for the data
|
||||
* @param dma The DMA buffer for the data
|
||||
* @param buflen Transfer length
|
||||
* @param sp Buffer for setup data
|
||||
* @param sp_dma DMA address of setup data buffer
|
||||
* @param flags Transfer flags
|
||||
* @param interval Polling interval for interrupt or isochronous transfers.
|
||||
*/
|
||||
extern _LONG_CALL_ void dwc_otg_hcd_urb_set_params(dwc_otg_hcd_urb_t * urb,
|
||||
void *urb_handle, void *buf,
|
||||
dwc_dma_t dma, uint32_t buflen, void *sp,
|
||||
dwc_dma_t sp_dma, uint32_t flags,
|
||||
uint16_t interval);
|
||||
|
||||
/** Gets status from dwc_otg_hcd_urb
|
||||
*
|
||||
* @param dwc_otg_urb DWC_OTG URB
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_hcd_urb_get_status(dwc_otg_hcd_urb_t * dwc_otg_urb);
|
||||
|
||||
/** Gets actual length from dwc_otg_hcd_urb
|
||||
*
|
||||
* @param dwc_otg_urb DWC_OTG URB
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_hcd_urb_get_actual_length(dwc_otg_hcd_urb_t *
|
||||
dwc_otg_urb);
|
||||
|
||||
/** Gets error count from dwc_otg_hcd_urb. Only for ISOC URBs
|
||||
*
|
||||
* @param dwc_otg_urb DWC_OTG URB
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_hcd_urb_get_error_count(dwc_otg_hcd_urb_t *
|
||||
dwc_otg_urb);
|
||||
|
||||
/** Set ISOC descriptor offset and length
|
||||
*
|
||||
* @param dwc_otg_urb DWC_OTG URB
|
||||
* @param desc_num ISOC descriptor number
|
||||
* @param offset Offset from beginig of buffer.
|
||||
* @param length Transaction length
|
||||
*/
|
||||
extern _LONG_CALL_ void dwc_otg_hcd_urb_set_iso_desc_params(dwc_otg_hcd_urb_t * dwc_otg_urb,
|
||||
int desc_num, uint32_t offset,
|
||||
uint32_t length);
|
||||
|
||||
/** Get status of ISOC descriptor, specified by desc_num
|
||||
*
|
||||
* @param dwc_otg_urb DWC_OTG URB
|
||||
* @param desc_num ISOC descriptor number
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_hcd_urb_get_iso_desc_status(dwc_otg_hcd_urb_t *
|
||||
dwc_otg_urb, int desc_num);
|
||||
|
||||
/** Get actual length of ISOC descriptor, specified by desc_num
|
||||
*
|
||||
* @param dwc_otg_urb DWC_OTG URB
|
||||
* @param desc_num ISOC descriptor number
|
||||
*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_hcd_urb_get_iso_desc_actual_length(dwc_otg_hcd_urb_t *
|
||||
dwc_otg_urb,
|
||||
int desc_num);
|
||||
|
||||
/** Queue URB. After transfer is completes, the complete callback will be called with the URB status
|
||||
*
|
||||
* @param dwc_otg_hcd The HCD
|
||||
* @param dwc_otg_urb DWC_OTG URB
|
||||
* @param ep_handle Out parameter for returning endpoint handle
|
||||
* @param atomic_alloc Flag to do atomic allocation if needed
|
||||
*
|
||||
* Returns -DWC_E_NO_DEVICE if no device is connected.
|
||||
* Returns -DWC_E_NO_MEMORY if there is no enough memory.
|
||||
* Returns 0 on success.
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_hcd_urb_enqueue(dwc_otg_hcd_t * dwc_otg_hcd,
|
||||
dwc_otg_hcd_urb_t * dwc_otg_urb,
|
||||
void **ep_handle, int atomic_alloc);
|
||||
|
||||
/** De-queue the specified URB
|
||||
*
|
||||
* @param dwc_otg_hcd The HCD
|
||||
* @param dwc_otg_urb DWC_OTG URB
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_hcd_urb_dequeue(dwc_otg_hcd_t * dwc_otg_hcd,
|
||||
dwc_otg_hcd_urb_t * dwc_otg_urb);
|
||||
|
||||
/** Frees resources in the DWC_otg controller related to a given endpoint.
|
||||
* Any URBs for the endpoint must already be dequeued.
|
||||
*
|
||||
* @param hcd The HCD
|
||||
* @param ep_handle Endpoint handle, returned by dwc_otg_hcd_urb_enqueue function
|
||||
* @param retry Number of retries if there are queued transfers.
|
||||
*
|
||||
* Returns -DWC_E_INVALID if invalid arguments are passed.
|
||||
* Returns 0 on success
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_hcd_endpoint_disable(dwc_otg_hcd_t * hcd, void *ep_handle,
|
||||
int retry);
|
||||
|
||||
/* Resets the data toggle in qh structure. This function can be called from
|
||||
* usb_clear_halt routine.
|
||||
*
|
||||
* @param hcd The HCD
|
||||
* @param ep_handle Endpoint handle, returned by dwc_otg_hcd_urb_enqueue function
|
||||
*
|
||||
* Returns -DWC_E_INVALID if invalid arguments are passed.
|
||||
* Returns 0 on success
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_hcd_endpoint_reset(dwc_otg_hcd_t * hcd, void *ep_handle);
|
||||
|
||||
/** Returns 1 if status of specified port is changed and 0 otherwise.
|
||||
*
|
||||
* @param hcd The HCD
|
||||
* @param port Port number
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_hcd_is_status_changed(dwc_otg_hcd_t * hcd, int port);
|
||||
|
||||
/** Call this function to check if bandwidth was allocated for specified endpoint.
|
||||
* Only for ISOC and INTERRUPT endpoints.
|
||||
*
|
||||
* @param hcd The HCD
|
||||
* @param ep_handle Endpoint handle
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_hcd_is_bandwidth_allocated(dwc_otg_hcd_t * hcd,
|
||||
void *ep_handle);
|
||||
|
||||
/** Call this function to check if bandwidth was freed for specified endpoint.
|
||||
*
|
||||
* @param hcd The HCD
|
||||
* @param ep_handle Endpoint handle
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_hcd_is_bandwidth_freed(dwc_otg_hcd_t * hcd, void *ep_handle);
|
||||
|
||||
/** Returns bandwidth allocated for specified endpoint in microseconds.
|
||||
* Only for ISOC and INTERRUPT endpoints.
|
||||
*
|
||||
* @param hcd The HCD
|
||||
* @param ep_handle Endpoint handle
|
||||
*/
|
||||
extern _LONG_CALL_ uint8_t dwc_otg_hcd_get_ep_bandwidth(dwc_otg_hcd_t * hcd,
|
||||
void *ep_handle);
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* __DWC_HCD_IF_H__ */
|
||||
#endif /* DWC_DEVICE_ONLY */
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
#ifndef _DWC_OS_DEP_H_
|
||||
#define _DWC_OS_DEP_H_
|
||||
#include "errno.h"
|
||||
|
||||
#endif /* _DWC_OS_DEP_H_ */
|
||||
|
|
@ -0,0 +1,271 @@
|
|||
/* ==========================================================================
|
||||
* $File: //dwh/usb_iip/dev/software/otg/linux/drivers/dwc_otg_pcd.h $
|
||||
* $Revision: #49 $
|
||||
* $Date: 2013/05/16 $
|
||||
* $Change: 2231774 $
|
||||
*
|
||||
* Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
|
||||
* "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
|
||||
* otherwise expressly agreed to in writing between Synopsys and you.
|
||||
*
|
||||
* The Software IS NOT an item of Licensed Software or Licensed Product under
|
||||
* any End User Software License Agreement or Agreement for Licensed Product
|
||||
* with Synopsys or any supplement thereto. You are permitted to use and
|
||||
* redistribute this Software in source and binary forms, with or without
|
||||
* modification, provided that redistributions of source code must retain this
|
||||
* notice. You may not view, use, disclose, copy or distribute this file or
|
||||
* any information contained herein except pursuant to this license grant from
|
||||
* Synopsys. If you do not agree with this notice, including the disclaimer
|
||||
* below, then you are not authorized to use the Software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
* ========================================================================== */
|
||||
#if 1//ndef DWC_HOST_ONLY
|
||||
#if !defined(__DWC_PCD_H__)
|
||||
#define __DWC_PCD_H__
|
||||
|
||||
#include "dwc_otg_os_dep.h"
|
||||
#include "usb.h"
|
||||
#include "dwc_otg_cil.h"
|
||||
#include "dwc_otg_pcd_if.h"
|
||||
struct cfiobject;
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* This file contains the structures, constants, and interfaces for
|
||||
* the Perpherial Contoller Driver (PCD).
|
||||
*
|
||||
* The Peripheral Controller Driver (PCD) for Linux will implement the
|
||||
* Gadget API, so that the existing Gadget drivers can be used. For
|
||||
* the Mass Storage Function driver the File-backed USB Storage Gadget
|
||||
* (FBS) driver will be used. The FBS driver supports the
|
||||
* Control-Bulk (CB), Control-Bulk-Interrupt (CBI), and Bulk-Only
|
||||
* transports.
|
||||
*
|
||||
*/
|
||||
|
||||
/** Invalid DMA Address */
|
||||
#define DWC_DMA_ADDR_INVALID (~(dwc_dma_t)0)
|
||||
|
||||
/** Max Transfer size for any EP */
|
||||
#define DDMA_MAX_TRANSFER_SIZE 65535
|
||||
|
||||
/**
|
||||
* Get the pointer to the core_if from the pcd pointer.
|
||||
*/
|
||||
#define GET_CORE_IF( _pcd ) (_pcd->core_if)
|
||||
|
||||
/**
|
||||
* States of EP0.
|
||||
*/
|
||||
typedef enum ep0_state {
|
||||
EP0_DISCONNECT, /* no host */
|
||||
EP0_IDLE,
|
||||
EP0_IN_DATA_PHASE,
|
||||
EP0_OUT_DATA_PHASE,
|
||||
EP0_IN_STATUS_PHASE,
|
||||
EP0_OUT_STATUS_PHASE,
|
||||
EP0_STALL,
|
||||
} ep0state_e;
|
||||
|
||||
/** Fordward declaration.*/
|
||||
struct dwc_otg_pcd;
|
||||
|
||||
/** DWC_otg iso request structure.
|
||||
*
|
||||
*/
|
||||
typedef struct usb_iso_request dwc_otg_pcd_iso_request_t;
|
||||
|
||||
#ifdef DWC_UTE_PER_IO
|
||||
XXX
|
||||
/**
|
||||
* This shall be the exact analogy of the same type structure defined in the
|
||||
* usb_gadget.h. Each descriptor contains
|
||||
*/
|
||||
struct dwc_iso_pkt_desc_port {
|
||||
uint32_t offset;
|
||||
uint32_t length; /* expected length */
|
||||
uint32_t actual_length;
|
||||
uint32_t status;
|
||||
};
|
||||
|
||||
struct dwc_iso_xreq_port {
|
||||
/** transfer/submission flag */
|
||||
uint32_t tr_sub_flags;
|
||||
/** Start the request ASAP */
|
||||
#define DWC_EREQ_TF_ASAP 0x00000002
|
||||
/** Just enqueue the request w/o initiating a transfer */
|
||||
#define DWC_EREQ_TF_ENQUEUE 0x00000004
|
||||
|
||||
/**
|
||||
* count of ISO packets attached to this request - shall
|
||||
* not exceed the pio_alloc_pkt_count
|
||||
*/
|
||||
uint32_t pio_pkt_count;
|
||||
/** count of ISO packets allocated for this request */
|
||||
uint32_t pio_alloc_pkt_count;
|
||||
/** number of ISO packet errors */
|
||||
uint32_t error_count;
|
||||
/** reserved for future extension */
|
||||
uint32_t res;
|
||||
/** Will be allocated and freed in the UTE gadget and based on the CFC value */
|
||||
struct dwc_iso_pkt_desc_port *per_io_frame_descs;
|
||||
};
|
||||
#endif
|
||||
/** DWC_otg request structure.
|
||||
* This structure is a list of requests.
|
||||
*/
|
||||
typedef struct dwc_otg_pcd_request {
|
||||
void *priv;
|
||||
void *buf;
|
||||
dwc_dma_t dma;
|
||||
uint32_t length;
|
||||
uint32_t actual;
|
||||
unsigned sent_zlp:1;
|
||||
/**
|
||||
* Used instead of original buffer if
|
||||
* it(physical address) is not dword-aligned.
|
||||
**/
|
||||
uint8_t *dw_align_buf;
|
||||
dwc_dma_t dw_align_buf_dma;
|
||||
|
||||
DWC_CIRCLEQ_ENTRY(dwc_otg_pcd_request) queue_entry;
|
||||
#ifdef DWC_UTE_PER_IO
|
||||
struct dwc_iso_xreq_port ext_req;
|
||||
//void *priv_ereq_nport; /* */
|
||||
#endif
|
||||
} dwc_otg_pcd_request_t;
|
||||
|
||||
DWC_CIRCLEQ_HEAD(req_list, dwc_otg_pcd_request);
|
||||
|
||||
/** PCD EP structure.
|
||||
* This structure describes an EP, there is an array of EPs in the PCD
|
||||
* structure.
|
||||
*/
|
||||
typedef struct dwc_otg_pcd_ep {
|
||||
/** USB EP Descriptor */
|
||||
const usb_endpoint_descriptor_t *desc;
|
||||
|
||||
/** queue of dwc_otg_pcd_requests. */
|
||||
struct req_list queue;
|
||||
unsigned stopped:1;
|
||||
unsigned disabling:1;
|
||||
unsigned dma:1;
|
||||
unsigned queue_sof:1;
|
||||
|
||||
#ifdef DWC_EN_ISOC
|
||||
/** ISOC req handle passed */
|
||||
void *iso_req_handle;
|
||||
#endif //_EN_ISOC_
|
||||
|
||||
/** DWC_otg ep data. */
|
||||
dwc_ep_t dwc_ep;
|
||||
|
||||
/** Pointer to PCD */
|
||||
struct dwc_otg_pcd *pcd;
|
||||
|
||||
void *priv;
|
||||
} dwc_otg_pcd_ep_t;
|
||||
|
||||
/** DWC_otg PCD Structure.
|
||||
* This structure encapsulates the data for the dwc_otg PCD.
|
||||
*/
|
||||
struct dwc_otg_pcd {
|
||||
const struct dwc_otg_pcd_function_ops *fops;
|
||||
/** The DWC otg device pointer */
|
||||
struct dwc_otg_device *otg_dev;
|
||||
/** Core Interface */
|
||||
dwc_otg_core_if_t *core_if;
|
||||
/** State of EP0 */
|
||||
ep0state_e ep0state;
|
||||
/** EP0 Request is pending */
|
||||
unsigned ep0_pending:1;
|
||||
/** Indicates when SET CONFIGURATION Request is in process */
|
||||
unsigned request_config:1;
|
||||
/** The state of the Remote Wakeup Enable. */
|
||||
unsigned remote_wakeup_enable:1;
|
||||
/** The state of the B-Device HNP Enable. */
|
||||
unsigned b_hnp_enable:1;
|
||||
/** The state of A-Device HNP Support. */
|
||||
unsigned a_hnp_support:1;
|
||||
/** The state of the A-Device Alt HNP support. */
|
||||
unsigned a_alt_hnp_support:1;
|
||||
/** Count of pending Requests */
|
||||
unsigned request_pending;
|
||||
|
||||
/** SETUP packet for EP0
|
||||
* This structure is allocated as a DMA buffer on PCD initialization
|
||||
* with enough space for up to 3 setup packets.
|
||||
*/
|
||||
union {
|
||||
usb_device_request_t req;
|
||||
uint32_t d32[2];
|
||||
} *setup_pkt;
|
||||
|
||||
dwc_dma_t setup_pkt_dma_handle;
|
||||
|
||||
/* Additional buffer and flag for CTRL_WR premature case */
|
||||
uint8_t *backup_buf;
|
||||
unsigned data_terminated;
|
||||
|
||||
/** 2-byte dma buffer used to return status from GET_STATUS */
|
||||
uint16_t *status_buf;
|
||||
dwc_dma_t status_buf_dma_handle;
|
||||
|
||||
/** EP0 */
|
||||
dwc_otg_pcd_ep_t ep0;
|
||||
|
||||
/** Array of IN EPs. */
|
||||
dwc_otg_pcd_ep_t in_ep[MAX_EPS_CHANNELS - 1];
|
||||
/** Array of OUT EPs. */
|
||||
dwc_otg_pcd_ep_t out_ep[MAX_EPS_CHANNELS - 1];
|
||||
/** number of valid EPs in the above array. */
|
||||
// unsigned num_eps : 4;
|
||||
dwc_spinlock_t *lock;
|
||||
|
||||
/** Tasklet to defer starting of TEST mode transmissions until
|
||||
* Status Phase has been completed.
|
||||
*/
|
||||
dwc_tasklet_t *test_mode_tasklet;
|
||||
|
||||
/** Tasklet to delay starting of xfer in DMA mode */
|
||||
dwc_tasklet_t *start_xfer_tasklet;
|
||||
|
||||
/** The test mode to enter when the tasklet is executed. */
|
||||
unsigned test_mode;
|
||||
/** The cfi_api structure that implements most of the CFI API
|
||||
* and OTG specific core configuration functionality
|
||||
*/
|
||||
#ifdef DWC_UTE_CFI
|
||||
struct cfiobject *cfi;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
//FIXME this functions should be static, and this prototypes should be removed
|
||||
extern _LONG_CALL_ void dwc_otg_request_nuke(dwc_otg_pcd_ep_t * ep);
|
||||
extern _LONG_CALL_ void dwc_otg_request_done(dwc_otg_pcd_ep_t * ep,
|
||||
dwc_otg_pcd_request_t * req, int32_t status);
|
||||
|
||||
_LONG_CALL_ void dwc_otg_iso_buffer_done(dwc_otg_pcd_t * pcd, dwc_otg_pcd_ep_t * ep,
|
||||
void *req_handle);
|
||||
extern _LONG_CALL_ void dwc_otg_pcd_start_iso_ddma(dwc_otg_core_if_t * core_if,
|
||||
dwc_otg_pcd_ep_t * ep);
|
||||
|
||||
extern _LONG_CALL_ void do_test_mode(void *data);
|
||||
|
||||
extern _LONG_CALL_ void dwc_pcd_data_init(VOID);
|
||||
|
||||
#endif
|
||||
#endif /* DWC_HOST_ONLY */
|
||||
|
|
@ -0,0 +1,367 @@
|
|||
/* ==========================================================================
|
||||
* $File: //dwh/usb_iip/dev/software/otg/linux/drivers/dwc_otg_pcd_if.h $
|
||||
* $Revision: #13 $
|
||||
* $Date: 2012/12/12 $
|
||||
* $Change: 2125019 $
|
||||
*
|
||||
* Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
|
||||
* "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
|
||||
* otherwise expressly agreed to in writing between Synopsys and you.
|
||||
*
|
||||
* The Software IS NOT an item of Licensed Software or Licensed Product under
|
||||
* any End User Software License Agreement or Agreement for Licensed Product
|
||||
* with Synopsys or any supplement thereto. You are permitted to use and
|
||||
* redistribute this Software in source and binary forms, with or without
|
||||
* modification, provided that redistributions of source code must retain this
|
||||
* notice. You may not view, use, disclose, copy or distribute this file or
|
||||
* any information contained herein except pursuant to this license grant from
|
||||
* Synopsys. If you do not agree with this notice, including the disclaimer
|
||||
* below, then you are not authorized to use the Software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
* ========================================================================== */
|
||||
#if 1//ndef DWC_HOST_ONLY
|
||||
|
||||
#if !defined(__DWC_PCD_IF_H__)
|
||||
#define __DWC_PCD_IF_H__
|
||||
|
||||
//#include "dwc_os.h"
|
||||
#include "dwc_otg_core_if.h"
|
||||
|
||||
/** @file
|
||||
* This file defines DWC_OTG PCD Core API.
|
||||
*/
|
||||
|
||||
struct dwc_otg_pcd;
|
||||
typedef struct dwc_otg_pcd dwc_otg_pcd_t;
|
||||
|
||||
/** Maxpacket size for EP0 */
|
||||
#define MAX_EP0_SIZE 64
|
||||
/** Maxpacket size for any EP */
|
||||
#define MAX_PACKET_SIZE 2048
|
||||
|
||||
/** @name Function Driver Callbacks */
|
||||
/** @{ */
|
||||
|
||||
/** This function will be called whenever a previously queued request has
|
||||
* completed. The status value will be set to -DWC_E_SHUTDOWN to indicated a
|
||||
* failed or aborted transfer, or -DWC_E_RESTART to indicate the device was reset,
|
||||
* or -DWC_E_TIMEOUT to indicate it timed out, or -DWC_E_INVALID to indicate invalid
|
||||
* parameters. */
|
||||
typedef int (*dwc_completion_cb_t) (dwc_otg_pcd_t * pcd, void *ep_handle,
|
||||
void *req_handle, int32_t status,
|
||||
uint32_t actual);
|
||||
/**
|
||||
* This function will be called whenever a previousle queued ISOC request has
|
||||
* completed. Count of ISOC packets could be read using dwc_otg_pcd_get_iso_packet_count
|
||||
* function.
|
||||
* The status of each ISOC packet could be read using dwc_otg_pcd_get_iso_packet_*
|
||||
* functions.
|
||||
*/
|
||||
typedef int (*dwc_isoc_completion_cb_t) (dwc_otg_pcd_t * pcd, void *ep_handle,
|
||||
void *req_handle, int proc_buf_num);
|
||||
/** This function should handle any SETUP request that cannot be handled by the
|
||||
* PCD Core. This includes most GET_DESCRIPTORs, SET_CONFIGS, Any
|
||||
* class-specific requests, etc. The function must non-blocking.
|
||||
*
|
||||
* Returns 0 on success.
|
||||
* Returns -DWC_E_NOT_SUPPORTED if the request is not supported.
|
||||
* Returns -DWC_E_INVALID if the setup request had invalid parameters or bytes.
|
||||
* Returns -DWC_E_SHUTDOWN on any other error. */
|
||||
typedef int (*dwc_setup_cb_t) (dwc_otg_pcd_t * pcd, uint8_t * bytes);
|
||||
/** This is called whenever the device has been disconnected. The function
|
||||
* driver should take appropriate action to clean up all pending requests in the
|
||||
* PCD Core, remove all endpoints (except ep0), and initialize back to reset
|
||||
* state. */
|
||||
typedef int (*dwc_disconnect_cb_t) (dwc_otg_pcd_t * pcd);
|
||||
/** This function is called when device has been connected. */
|
||||
typedef int (*dwc_connect_cb_t) (dwc_otg_pcd_t * pcd, int speed);
|
||||
/** This function is called when device has been suspended */
|
||||
typedef int (*dwc_suspend_cb_t) (dwc_otg_pcd_t * pcd);
|
||||
/** This function is called when device has received LPM tokens, i.e.
|
||||
* device has been sent to sleep state. */
|
||||
typedef int (*dwc_sleep_cb_t) (dwc_otg_pcd_t * pcd);
|
||||
/** This function is called when device has been resumed
|
||||
* from suspend(L2) or L1 sleep state. */
|
||||
typedef int (*dwc_resume_cb_t) (dwc_otg_pcd_t * pcd);
|
||||
/** This function is called whenever hnp params has been changed.
|
||||
* User can call get_b_hnp_enable, get_a_hnp_support, get_a_alt_hnp_support functions
|
||||
* to get hnp parameters. */
|
||||
typedef int (*dwc_hnp_params_changed_cb_t) (dwc_otg_pcd_t * pcd);
|
||||
/** This function is called whenever USB RESET is detected. */
|
||||
typedef int (*dwc_reset_cb_t) (dwc_otg_pcd_t * pcd);
|
||||
|
||||
typedef int (*cfi_setup_cb_t) (dwc_otg_pcd_t * pcd, void *ctrl_req_bytes);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param ep_handle Void pointer to the usb_ep structure
|
||||
* @param ereq_port Pointer to the extended request structure created in the
|
||||
* portable part.
|
||||
*/
|
||||
typedef int (*xiso_completion_cb_t) (dwc_otg_pcd_t * pcd, void *ep_handle,
|
||||
void *req_handle, int32_t status,
|
||||
void *ereq_port);
|
||||
/** Function Driver Ops Data Structure */
|
||||
struct dwc_otg_pcd_function_ops {
|
||||
dwc_connect_cb_t connect;
|
||||
dwc_disconnect_cb_t disconnect;
|
||||
dwc_setup_cb_t setup;
|
||||
dwc_completion_cb_t complete;
|
||||
dwc_isoc_completion_cb_t isoc_complete;
|
||||
dwc_suspend_cb_t suspend;
|
||||
dwc_sleep_cb_t sleep;
|
||||
dwc_resume_cb_t resume;
|
||||
dwc_reset_cb_t reset;
|
||||
dwc_hnp_params_changed_cb_t hnp_changed;
|
||||
cfi_setup_cb_t cfi_setup;
|
||||
#ifdef DWC_UTE_PER_IO
|
||||
xiso_completion_cb_t xisoc_complete;
|
||||
#endif
|
||||
};
|
||||
/** @} */
|
||||
|
||||
/** @name Function Driver Functions */
|
||||
/** @{ */
|
||||
|
||||
/** Call this function to get pointer on dwc_otg_pcd_t,
|
||||
* this pointer will be used for all PCD API functions.
|
||||
*
|
||||
* @param core_if The DWC_OTG Core
|
||||
*/
|
||||
extern _LONG_CALL_ dwc_otg_pcd_t *dwc_otg_pcd_init(dwc_otg_core_if_t * core_if);
|
||||
|
||||
/** Frees PCD allocated by dwc_otg_pcd_init
|
||||
*
|
||||
* @param pcd The PCD
|
||||
*/
|
||||
extern _LONG_CALL_ void dwc_otg_pcd_remove(dwc_otg_pcd_t * pcd);
|
||||
|
||||
/** Call this to bind the function driver to the PCD Core.
|
||||
*
|
||||
* @param pcd Pointer on dwc_otg_pcd_t returned by dwc_otg_pcd_init function.
|
||||
* @param fops The Function Driver Ops data structure containing pointers to all callbacks.
|
||||
*/
|
||||
extern _LONG_CALL_ void dwc_otg_pcd_start(dwc_otg_pcd_t * pcd,
|
||||
const struct dwc_otg_pcd_function_ops *fops);
|
||||
|
||||
/** Enables an endpoint for use. This function enables an endpoint in
|
||||
* the PCD. The endpoint is described by the ep_desc which has the
|
||||
* same format as a USB ep descriptor. The ep_handle parameter is used to refer
|
||||
* to the endpoint from other API functions and in callbacks. Normally this
|
||||
* should be called after a SET_CONFIGURATION/SET_INTERFACE to configure the
|
||||
* core for that interface.
|
||||
*
|
||||
* Returns -DWC_E_INVALID if invalid parameters were passed.
|
||||
* Returns -DWC_E_SHUTDOWN if any other error ocurred.
|
||||
* Returns 0 on success.
|
||||
*
|
||||
* @param pcd The PCD
|
||||
* @param ep_desc Endpoint descriptor
|
||||
* @param ep_handle Handle on endpoint, that will be used to identify endpoint.
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_pcd_ep_enable(dwc_otg_pcd_t * pcd,
|
||||
const uint8_t * ep_desc, void *ep_handle);
|
||||
|
||||
/** Disable the endpoint referenced by ep_handle.
|
||||
*
|
||||
* Returns -DWC_E_INVALID if invalid parameters were passed.
|
||||
* Returns -DWC_E_SHUTDOWN if any other error occurred.
|
||||
* Returns 0 on success. */
|
||||
extern _LONG_CALL_ int dwc_otg_pcd_ep_disable(dwc_otg_pcd_t * pcd, void *ep_handle);
|
||||
|
||||
/** Queue a data transfer request on the endpoint referenced by ep_handle.
|
||||
* After the transfer is completes, the complete callback will be called with
|
||||
* the request status.
|
||||
*
|
||||
* @param pcd The PCD
|
||||
* @param ep_handle The handle of the endpoint
|
||||
* @param buf The buffer for the data
|
||||
* @param dma_buf The DMA buffer for the data
|
||||
* @param buflen The length of the data transfer
|
||||
* @param zero Specifies whether to send zero length last packet.
|
||||
* @param req_handle Set this handle to any value to use to reference this
|
||||
* request in the ep_dequeue function or from the complete callback
|
||||
* @param atomic_alloc If driver need to perform atomic allocations
|
||||
* for internal data structures.
|
||||
*
|
||||
* Returns -DWC_E_INVALID if invalid parameters were passed.
|
||||
* Returns -DWC_E_SHUTDOWN if any other error ocurred.
|
||||
* Returns 0 on success. */
|
||||
extern _LONG_CALL_ int dwc_otg_pcd_ep_queue(dwc_otg_pcd_t * pcd, void *ep_handle,
|
||||
uint8_t * buf, dwc_dma_t dma_buf,
|
||||
uint32_t buflen, int zero, void *req_handle,
|
||||
int atomic_alloc);
|
||||
#ifdef DWC_UTE_PER_IO
|
||||
XXXX
|
||||
/**
|
||||
*
|
||||
* @param ereq_nonport Pointer to the extended request part of the
|
||||
* usb_request structure defined in usb_gadget.h file.
|
||||
*/
|
||||
extern int dwc_otg_pcd_xiso_ep_queue(dwc_otg_pcd_t * pcd, void *ep_handle,
|
||||
uint8_t * buf, dwc_dma_t dma_buf,
|
||||
uint32_t buflen, int zero,
|
||||
void *req_handle, int atomic_alloc,
|
||||
void *ereq_nonport);
|
||||
|
||||
#endif
|
||||
|
||||
/** De-queue the specified data transfer that has not yet completed.
|
||||
*
|
||||
* Returns -DWC_E_INVALID if invalid parameters were passed.
|
||||
* Returns -DWC_E_SHUTDOWN if any other error ocurred.
|
||||
* Returns 0 on success. */
|
||||
extern _LONG_CALL_ int dwc_otg_pcd_ep_dequeue(dwc_otg_pcd_t * pcd, void *ep_handle,
|
||||
void *req_handle);
|
||||
|
||||
/** Halt (STALL) an endpoint or clear it.
|
||||
*
|
||||
* Returns -DWC_E_INVALID if invalid parameters were passed.
|
||||
* Returns -DWC_E_SHUTDOWN if any other error ocurred.
|
||||
* Returns -DWC_E_AGAIN if the STALL cannot be sent and must be tried again later
|
||||
* Returns 0 on success. */
|
||||
extern _LONG_CALL_ int dwc_otg_pcd_ep_halt(dwc_otg_pcd_t * pcd, void *ep_handle, int value);
|
||||
|
||||
/** This function should be called on every hardware interrupt */
|
||||
extern _LONG_CALL_ int32_t dwc_otg_pcd_handle_intr(dwc_otg_pcd_t * pcd);
|
||||
|
||||
/** This function returns current frame number */
|
||||
extern _LONG_CALL_ int dwc_otg_pcd_get_frame_number(dwc_otg_pcd_t * pcd);
|
||||
|
||||
/**
|
||||
* Start isochronous transfers on the endpoint referenced by ep_handle.
|
||||
* For isochronous transfers duble buffering is used.
|
||||
* After processing each of buffers comlete callback will be called with
|
||||
* status for each transaction.
|
||||
*
|
||||
* @param pcd The PCD
|
||||
* @param ep_handle The handle of the endpoint
|
||||
* @param buf0 The virtual address of first data buffer
|
||||
* @param buf1 The virtual address of second data buffer
|
||||
* @param dma0 The DMA address of first data buffer
|
||||
* @param dma1 The DMA address of second data buffer
|
||||
* @param sync_frame Data pattern frame number
|
||||
* @param dp_frame Data size for pattern frame
|
||||
* @param data_per_frame Data size for regular frame
|
||||
* @param start_frame Frame number to start transfers, if -1 then start transfers ASAP.
|
||||
* @param buf_proc_intrvl Interval of ISOC Buffer processing
|
||||
* @param req_handle Handle of ISOC request
|
||||
* @param atomic_alloc Specefies whether to perform atomic allocation for
|
||||
* internal data structures.
|
||||
*
|
||||
* Returns -DWC_E_NO_MEMORY if there is no enough memory.
|
||||
* Returns -DWC_E_INVALID if incorrect arguments are passed to the function.
|
||||
* Returns -DW_E_SHUTDOWN for any other error.
|
||||
* Returns 0 on success
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_pcd_iso_ep_start(dwc_otg_pcd_t * pcd, void *ep_handle,
|
||||
uint8_t * buf0, uint8_t * buf1,
|
||||
dwc_dma_t dma0, dwc_dma_t dma1,
|
||||
int sync_frame, int dp_frame,
|
||||
int data_per_frame, int start_frame,
|
||||
int buf_proc_intrvl, void *req_handle,
|
||||
int atomic_alloc);
|
||||
|
||||
/** Stop ISOC transfers on endpoint referenced by ep_handle.
|
||||
*
|
||||
* @param pcd The PCD
|
||||
* @param ep_handle The handle of the endpoint
|
||||
* @param req_handle Handle of ISOC request
|
||||
*
|
||||
* Returns -DWC_E_INVALID if incorrect arguments are passed to the function
|
||||
* Returns 0 on success
|
||||
*/
|
||||
_LONG_CALL_ int dwc_otg_pcd_iso_ep_stop(dwc_otg_pcd_t * pcd, void *ep_handle,
|
||||
void *req_handle);
|
||||
|
||||
/** Get ISOC packet status.
|
||||
*
|
||||
* @param pcd The PCD
|
||||
* @param ep_handle The handle of the endpoint
|
||||
* @param iso_req_handle Isochronoush request handle
|
||||
* @param packet Number of packet
|
||||
* @param status Out parameter for returning status
|
||||
* @param actual Out parameter for returning actual length
|
||||
* @param offset Out parameter for returning offset
|
||||
*
|
||||
*/
|
||||
extern _LONG_CALL_ void dwc_otg_pcd_get_iso_packet_params(dwc_otg_pcd_t * pcd,
|
||||
void *ep_handle,
|
||||
void *iso_req_handle, int packet,
|
||||
int *status, int *actual,
|
||||
int *offset);
|
||||
|
||||
/** Get ISOC packet count.
|
||||
*
|
||||
* @param pcd The PCD
|
||||
* @param ep_handle The handle of the endpoint
|
||||
* @param iso_req_handle
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_pcd_get_iso_packet_count(dwc_otg_pcd_t * pcd,
|
||||
void *ep_handle,
|
||||
void *iso_req_handle);
|
||||
|
||||
/** This function starts the SRP Protocol if no session is in progress. If
|
||||
* a session is already in progress, but the device is suspended,
|
||||
* remote wakeup signaling is started.
|
||||
*/
|
||||
extern _LONG_CALL_ int dwc_otg_pcd_wakeup(dwc_otg_pcd_t * pcd);
|
||||
|
||||
/** This function returns 1 if LPM support is enabled, and 0 otherwise. */
|
||||
extern _LONG_CALL_ int dwc_otg_pcd_is_lpm_enabled(dwc_otg_pcd_t * pcd);
|
||||
|
||||
/** This function returns 1 if LPM Errata support is enabled, and 0 otherwise. */
|
||||
extern _LONG_CALL_ int dwc_otg_pcd_is_besl_enabled(dwc_otg_pcd_t * pcd);
|
||||
|
||||
/** This function returns baseline_besl module parametr. */
|
||||
extern _LONG_CALL_ int dwc_otg_pcd_get_param_baseline_besl(dwc_otg_pcd_t * pcd);
|
||||
|
||||
/** This function returns deep_besl module parametr. */
|
||||
extern _LONG_CALL_ int dwc_otg_pcd_get_param_deep_besl(dwc_otg_pcd_t * pcd);
|
||||
|
||||
/** This function returns 1 if remote wakeup is allowed and 0, otherwise. */
|
||||
extern _LONG_CALL_ int dwc_otg_pcd_get_rmwkup_enable(dwc_otg_pcd_t * pcd);
|
||||
|
||||
/** Initiate SRP */
|
||||
extern _LONG_CALL_ void dwc_otg_pcd_initiate_srp(dwc_otg_pcd_t * pcd);
|
||||
|
||||
/** Starts remote wakeup signaling. */
|
||||
extern _LONG_CALL_ void dwc_otg_pcd_remote_wakeup(dwc_otg_pcd_t * pcd, int set);
|
||||
|
||||
/** Starts micorsecond soft disconnect. */
|
||||
extern _LONG_CALL_ void dwc_otg_pcd_disconnect_us(dwc_otg_pcd_t * pcd, int no_of_usecs);
|
||||
/** This function returns whether device is dualspeed.*/
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_pcd_is_dualspeed(dwc_otg_pcd_t * pcd);
|
||||
|
||||
/** This function returns whether device is otg. */
|
||||
extern _LONG_CALL_ uint32_t dwc_otg_pcd_is_otg(dwc_otg_pcd_t * pcd);
|
||||
|
||||
/** These functions allow to get hnp parameters */
|
||||
extern _LONG_CALL_ uint32_t get_b_hnp_enable(dwc_otg_pcd_t * pcd);
|
||||
extern _LONG_CALL_ uint32_t get_a_hnp_support(dwc_otg_pcd_t * pcd);
|
||||
extern _LONG_CALL_ uint32_t get_a_alt_hnp_support(dwc_otg_pcd_t * pcd);
|
||||
|
||||
/** CFI specific Interface functions */
|
||||
/** Allocate a cfi buffer */
|
||||
extern _LONG_CALL_ uint8_t *cfiw_ep_alloc_buffer(dwc_otg_pcd_t * pcd, void *pep,
|
||||
dwc_dma_t * addr, size_t buflen,
|
||||
int flags);
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* __DWC_PCD_IF_H__ */
|
||||
|
||||
#endif /* DWC_HOST_ONLY */
|
||||
File diff suppressed because it is too large
Load diff
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue