mirror of
https://github.com/ADElectronics/RTL00_WEB_VS.git
synced 2026-07-15 13:35:40 +00:00
update
This commit is contained in:
parent
6a1f93f17b
commit
764b020238
1201 changed files with 527271 additions and 1 deletions
69
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/bitband_io.c
Normal file
69
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/bitband_io.c
Normal file
|
|
@ -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;
|
||||
}
|
||||
|
||||
153
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/bitband_io.h
Normal file
153
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/bitband_io.h
Normal file
|
|
@ -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
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_32k.c
Normal file
305
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
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_adc.c
Normal file
1839
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_adc.c
Normal file
File diff suppressed because it is too large
Load diff
318
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_adc.h
Normal file
318
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
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_api.h
Normal file
126
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_
|
||||
23
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_common.c
Normal file
23
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_common.c
Normal file
|
|
@ -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;
|
||||
}
|
||||
17
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_common.h
Normal file
17
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_common.h
Normal file
|
|
@ -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
|
||||
214
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_crypto.h
Normal file
214
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_crypto.h
Normal file
|
|
@ -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
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_dac.c
Normal file
1561
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_dac.c
Normal file
File diff suppressed because it is too large
Load diff
314
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_dac.h
Normal file
314
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
|
||||
110
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_diag.h
Normal file
110
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_diag.h
Normal file
|
|
@ -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_
|
||||
337
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_efuse.c
Normal file
337
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_efuse.c
Normal file
|
|
@ -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
|
||||
39
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_efuse.h
Normal file
39
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_efuse.h
Normal file
|
|
@ -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
|
||||
|
||||
578
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_gdma.c
Normal file
578
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_gdma.c
Normal file
|
|
@ -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
|
||||
141
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_gdma.h
Normal file
141
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_gdma.h
Normal file
|
|
@ -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
|
||||
212
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_gpio.c
Normal file
212
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_gpio.c
Normal file
|
|
@ -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
|
||||
250
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_gpio.h
Normal file
250
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_gpio.h
Normal file
|
|
@ -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
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_i2c.c
Normal file
2941
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_i2c.c
Normal file
File diff suppressed because it is too large
Load diff
594
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_i2c.h
Normal file
594
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
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_i2s.c
Normal file
562
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
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_i2s.h
Normal file
347
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
|
||||
|
||||
112
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_irqn.h
Normal file
112
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_irqn.h
Normal file
|
|
@ -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_
|
||||
442
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_log_uart.c
Normal file
442
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_log_uart.c
Normal file
|
|
@ -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
|
||||
151
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_log_uart.h
Normal file
151
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_log_uart.h
Normal file
|
|
@ -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
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_mii.c
Normal file
134
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
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_mii.h
Normal file
191
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_
|
||||
|
||||
69
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_misc.c
Normal file
69
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_misc.c
Normal file
|
|
@ -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;
|
||||
}
|
||||
|
||||
56
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_misc.h
Normal file
56
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_misc.h
Normal file
|
|
@ -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_
|
||||
23
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_nfc.c
Normal file
23
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_nfc.c
Normal file
|
|
@ -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
|
||||
22
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_nfc.h
Normal file
22
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_nfc.h
Normal file
|
|
@ -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
|
||||
|
||||
31
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_pcm.c
Normal file
31
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_pcm.c
Normal file
|
|
@ -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
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_pcm.h
Normal file
104
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
|
||||
451
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_peri_on.h
Normal file
451
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_peri_on.h
Normal file
|
|
@ -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_
|
||||
|
||||
140
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_pinmux.c
Normal file
140
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_pinmux.c
Normal file
|
|
@ -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
|
||||
}
|
||||
75
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_pinmux.h
Normal file
75
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_pinmux.h
Normal file
|
|
@ -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_
|
||||
102
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_platform.h
Normal file
102
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_platform.h
Normal file
|
|
@ -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
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_pwm.c
Normal file
142
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"
|
||||
60
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_pwm.h
Normal file
60
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_pwm.h
Normal file
|
|
@ -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
|
||||
|
||||
273
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_sdio.h
Normal file
273
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_sdio.h
Normal file
|
|
@ -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_
|
||||
130
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_sdio_host.c
Normal file
130
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_sdio_host.c
Normal file
|
|
@ -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
|
||||
105
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_sdio_host.h
Normal file
105
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_sdio_host.h
Normal file
|
|
@ -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
|
||||
|
||||
1120
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_sdr_controller.c
Normal file
1120
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_sdr_controller.c
Normal file
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_"
|
||||
3484
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_soc_ps_monitor.c
Normal file
3484
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_soc_ps_monitor.c
Normal file
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_
|
||||
359
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_spi_flash.h
Normal file
359
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_spi_flash.h
Normal file
|
|
@ -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__
|
||||
1466
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_spi_flash_ram.c
Normal file
1466
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_spi_flash_ram.c
Normal file
File diff suppressed because it is too large
Load diff
689
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_ssi.c
Normal file
689
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
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_ssi.h
Normal file
336
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
|
||||
|
||||
38
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_timer.c
Normal file
38
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_timer.c
Normal file
|
|
@ -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
|
||||
96
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_timer.h
Normal file
96
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_timer.h
Normal file
|
|
@ -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
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_uart.c
Normal file
1112
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_uart.c
Normal file
File diff suppressed because it is too large
Load diff
257
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_uart.h
Normal file
257
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_uart.h
Normal file
|
|
@ -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
|
||||
|
||||
15
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_usb.h
Normal file
15
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_usb.h
Normal file
|
|
@ -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_
|
||||
252
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_util.h
Normal file
252
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/hal_util.h
Normal file
|
|
@ -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();
|
||||
769
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/ram_lib/rtl_boot.c
Normal file
769
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/ram_lib/rtl_boot.c
Normal file
|
|
@ -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);
|
||||
}
|
||||
279
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/ram_lib/startup.c
Normal file
279
RTLGDB/USDK/component/soc/realtek/8195a/fwlib/ram_lib/startup.c
Normal file
|
|
@ -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
|
|
@ -0,0 +1,149 @@
|
|||
#ifndef _GENERIC_ERRNO_H
|
||||
#define _GENERIC_ERRNO_H
|
||||
|
||||
#define EPERM 1 /* Operation not permitted */
|
||||
#define ENOENT 2 /* No such file or directory */
|
||||
#define ESRCH 3 /* No such process */
|
||||
#define EINTR 4 /* Interrupted system call */
|
||||
#define EIO 5 /* I/O error */
|
||||
#define ENXIO 6 /* No such device or address */
|
||||
#define E2BIG 7 /* Argument list too long */
|
||||
#define ENOEXEC 8 /* Exec format error */
|
||||
#define EBADF 9 /* Bad file number */
|
||||
#define ECHILD 10 /* No child processes */
|
||||
#define EAGAIN 11 /* Try again */
|
||||
#define ENOMEM 12 /* Out of memory */
|
||||
#define EACCES 13 /* Permission denied */
|
||||
#define EFAULT 14 /* Bad address */
|
||||
#define ENOTBLK 15 /* Block device required */
|
||||
#define EBUSY 16 /* Device or resource busy */
|
||||
#define EEXIST 17 /* File exists */
|
||||
#define EXDEV 18 /* Cross-device link */
|
||||
#define ENODEV 19 /* No such device */
|
||||
#define ENOTDIR 20 /* Not a directory */
|
||||
#define EISDIR 21 /* Is a directory */
|
||||
#define EINVAL 22 /* Invalid argument */
|
||||
#define ENFILE 23 /* File table overflow */
|
||||
#define EMFILE 24 /* Too many open files */
|
||||
#define ENOTTY 25 /* Not a typewriter */
|
||||
#define ETXTBSY 26 /* Text file busy */
|
||||
#define EFBIG 27 /* File too large */
|
||||
#define ENOSPC 28 /* No space left on device */
|
||||
#define ESPIPE 29 /* Illegal seek */
|
||||
#define EROFS 30 /* Read-only file system */
|
||||
#define EMLINK 31 /* Too many links */
|
||||
#define EPIPE 32 /* Broken pipe */
|
||||
#define EDOM 33 /* Math argument out of domain of func */
|
||||
#define ERANGE 34 /* Math result not representable */
|
||||
|
||||
#define EDEADLK 35 /* Resource deadlock would occur */
|
||||
#define ENAMETOOLONG 36 /* File name too long */
|
||||
#define ENOLCK 37 /* No record locks available */
|
||||
#define ENOSYS 38 /* Function not implemented */
|
||||
#define ENOTEMPTY 39 /* Directory not empty */
|
||||
#define ELOOP 40 /* Too many symbolic links encountered */
|
||||
#define EWOULDBLOCK EAGAIN /* Operation would block */
|
||||
#define ENOMSG 42 /* No message of desired type */
|
||||
#define EIDRM 43 /* Identifier removed */
|
||||
#define ECHRNG 44 /* Channel number out of range */
|
||||
#define EL2NSYNC 45 /* Level 2 not synchronized */
|
||||
#define EL3HLT 46 /* Level 3 halted */
|
||||
#define EL3RST 47 /* Level 3 reset */
|
||||
#define ELNRNG 48 /* Link number out of range */
|
||||
#define EUNATCH 49 /* Protocol driver not attached */
|
||||
#define ENOCSI 50 /* No CSI structure available */
|
||||
#define EL2HLT 51 /* Level 2 halted */
|
||||
#define EBADE 52 /* Invalid exchange */
|
||||
#define EBADR 53 /* Invalid request descriptor */
|
||||
#define EXFULL 54 /* Exchange full */
|
||||
#define ENOANO 55 /* No anode */
|
||||
#define EBADRQC 56 /* Invalid request code */
|
||||
#define EBADSLT 57 /* Invalid slot */
|
||||
|
||||
#define EDEADLOCK EDEADLK
|
||||
|
||||
#define EBFONT 59 /* Bad font file format */
|
||||
#define ENOSTR 60 /* Device not a stream */
|
||||
#define ENODATA 61 /* No data available */
|
||||
#define ETIME 62 /* Timer expired */
|
||||
#define ENOSR 63 /* Out of streams resources */
|
||||
#define ENONET 64 /* Machine is not on the network */
|
||||
#define ENOPKG 65 /* Package not installed */
|
||||
#define EREMOTE 66 /* Object is remote */
|
||||
#define ENOLINK 67 /* Link has been severed */
|
||||
#define EADV 68 /* Advertise error */
|
||||
#define ESRMNT 69 /* Srmount error */
|
||||
#define ECOMM 70 /* Communication error on send */
|
||||
#define EPROTO 71 /* Protocol error */
|
||||
#define EMULTIHOP 72 /* Multihop attempted */
|
||||
#define EDOTDOT 73 /* RFS specific error */
|
||||
#define EBADMSG 74 /* Not a data message */
|
||||
#define EOVERFLOW 75 /* Value too large for defined data type */
|
||||
#define ENOTUNIQ 76 /* Name not unique on network */
|
||||
#define EBADFD 77 /* File descriptor in bad state */
|
||||
#define EREMCHG 78 /* Remote address changed */
|
||||
#define ELIBACC 79 /* Can not access a needed shared library */
|
||||
#define ELIBBAD 80 /* Accessing a corrupted shared library */
|
||||
#define ELIBSCN 81 /* .lib section in a.out corrupted */
|
||||
#define ELIBMAX 82 /* Attempting to link in too many shared libraries */
|
||||
#define ELIBEXEC 83 /* Cannot exec a shared library directly */
|
||||
#define EILSEQ 84 /* Illegal byte sequence */
|
||||
#define ERESTART 85 /* Interrupted system call should be restarted */
|
||||
#define ESTRPIPE 86 /* Streams pipe error */
|
||||
#define EUSERS 87 /* Too many users */
|
||||
#define ENOTSOCK 88 /* Socket operation on non-socket */
|
||||
#define EDESTADDRREQ 89 /* Destination address required */
|
||||
#define EMSGSIZE 90 /* Message too long */
|
||||
#define EPROTOTYPE 91 /* Protocol wrong type for socket */
|
||||
#define ENOPROTOOPT 92 /* Protocol not available */
|
||||
#define EPROTONOSUPPORT 93 /* Protocol not supported */
|
||||
#define ESOCKTNOSUPPORT 94 /* Socket type not supported */
|
||||
#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
|
||||
#define EPFNOSUPPORT 96 /* Protocol family not supported */
|
||||
#define EAFNOSUPPORT 97 /* Address family not supported by protocol */
|
||||
#define EADDRINUSE 98 /* Address already in use */
|
||||
#define EADDRNOTAVAIL 99 /* Cannot assign requested address */
|
||||
#define ENETDOWN 100 /* Network is down */
|
||||
#define ENETUNREACH 101 /* Network is unreachable */
|
||||
#define ENETRESET 102 /* Network dropped connection because of reset */
|
||||
#define ECONNABORTED 103 /* Software caused connection abort */
|
||||
#define ECONNRESET 104 /* Connection reset by peer */
|
||||
#define ENOBUFS 105 /* No buffer space available */
|
||||
#define EISCONN 106 /* Transport endpoint is already connected */
|
||||
#define ENOTCONN 107 /* Transport endpoint is not connected */
|
||||
#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */
|
||||
#define ETOOMANYREFS 109 /* Too many references: cannot splice */
|
||||
#define ETIMEDOUT 110 /* Connection timed out */
|
||||
#define ECONNREFUSED 111 /* Connection refused */
|
||||
#define EHOSTDOWN 112 /* Host is down */
|
||||
#define EHOSTUNREACH 113 /* No route to host */
|
||||
#define EALREADY 114 /* Operation already in progress */
|
||||
#define EINPROGRESS 115 /* Operation now in progress */
|
||||
#define ESTALE 116 /* Stale NFS file handle */
|
||||
#define EUCLEAN 117 /* Structure needs cleaning */
|
||||
#define ENOTNAM 118 /* Not a XENIX named type file */
|
||||
#define ENAVAIL 119 /* No XENIX semaphores available */
|
||||
#define EISNAM 120 /* Is a named type file */
|
||||
#define EREMOTEIO 121 /* Remote I/O error */
|
||||
#define EDQUOT 122 /* Quota exceeded */
|
||||
|
||||
#define ENOMEDIUM 123 /* No medium found */
|
||||
#define EMEDIUMTYPE 124 /* Wrong medium type */
|
||||
#define ECANCELED 125 /* Operation Canceled */
|
||||
#define ENOKEY 126 /* Required key not available */
|
||||
#define EKEYEXPIRED 127 /* Key has expired */
|
||||
#define EKEYREVOKED 128 /* Key has been revoked */
|
||||
#define EKEYREJECTED 129 /* Key was rejected by service */
|
||||
|
||||
/* for robust mutexes */
|
||||
#define EOWNERDEAD 130 /* Owner died */
|
||||
#define ENOTRECOVERABLE 131 /* State not recoverable */
|
||||
|
||||
#define ERFKILL 132 /* Operation not possible due to RF-kill */
|
||||
|
||||
#define EHWPOISON 133 /* Memory page has hardware error */
|
||||
|
||||
|
||||
#define ENOTSUPP 524 /* Operation is not supported */
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* 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_OTG_H_
|
||||
#define _HAL_OTG_H_
|
||||
|
||||
#include "rtl8195a_otg.h"
|
||||
#include "dwc_otg_regs.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,164 @@
|
|||
#ifndef _HCD_H_
|
||||
#define _HCD_H_
|
||||
|
||||
|
||||
struct hc_driver {
|
||||
const char *description; /* "ehci-hcd" etc */
|
||||
const char *product_desc; /* product/vendor string */
|
||||
size_t hcd_priv_size; /* size of private data */
|
||||
|
||||
/* irq handler */
|
||||
//irqreturn_t (*irq) (struct usb_hcd *hcd);
|
||||
|
||||
int flags;
|
||||
#define HCD_MEMORY 0x0001 /* HC regs use memory (else I/O) */
|
||||
#define HCD_LOCAL_MEM 0x0002 /* HC needs local memory */
|
||||
#define HCD_SHARED 0x0004 /* Two (or more) usb_hcds share HW */
|
||||
#define HCD_USB11 0x0010 /* USB 1.1 */
|
||||
#define HCD_USB2 0x0020 /* USB 2.0 */
|
||||
#define HCD_USB3 0x0040 /* USB 3.0 */
|
||||
#define HCD_MASK 0x0070
|
||||
|
||||
/* called to init HCD and root hub */
|
||||
int (*reset) (struct usb_hcd *hcd);
|
||||
int (*start) (struct usb_hcd *hcd);
|
||||
|
||||
/* NOTE: these suspend/resume calls relate to the HC as
|
||||
* a whole, not just the root hub; they're for PCI bus glue.
|
||||
*/
|
||||
/* called after suspending the hub, before entering D3 etc */
|
||||
// int (*pci_suspend)(struct usb_hcd *hcd, bool do_wakeup);
|
||||
|
||||
/* called after entering D0 (etc), before resuming the hub */
|
||||
// int (*pci_resume)(struct usb_hcd *hcd, bool hibernated);
|
||||
|
||||
/* cleanly make HCD stop writing memory and doing I/O */
|
||||
void (*stop) (struct usb_hcd *hcd);
|
||||
|
||||
/* shutdown HCD */
|
||||
// void (*shutdown) (struct usb_hcd *hcd);
|
||||
|
||||
/* return current frame number */
|
||||
int (*get_frame_number) (struct usb_hcd *hcd);
|
||||
|
||||
/* manage i/o requests, device state */
|
||||
int (*urb_enqueue)(struct usb_hcd *hcd,
|
||||
struct urb *urb);//, gfp_t mem_flags);
|
||||
int (*urb_dequeue)(struct usb_hcd *hcd,
|
||||
struct urb *urb, int status);
|
||||
|
||||
/*
|
||||
* (optional) these hooks allow an HCD to override the default DMA
|
||||
* mapping and unmapping routines. In general, they shouldn't be
|
||||
* necessary unless the host controller has special DMA requirements,
|
||||
* such as alignment contraints. If these are not specified, the
|
||||
* general usb_hcd_(un)?map_urb_for_dma functions will be used instead
|
||||
* (and it may be a good idea to call these functions in your HCD
|
||||
* implementation)
|
||||
*/
|
||||
#if 0
|
||||
int (*map_urb_for_dma)(struct usb_hcd *hcd, struct urb *urb,
|
||||
gfp_t mem_flags);
|
||||
void (*unmap_urb_for_dma)(struct usb_hcd *hcd, struct urb *urb);
|
||||
#endif
|
||||
/* hw synch, freeing endpoint resources that urb_dequeue can't */
|
||||
void (*endpoint_disable)(struct usb_hcd *hcd,
|
||||
struct usb_host_endpoint *ep);
|
||||
|
||||
/* (optional) reset any endpoint state such as sequence number
|
||||
and current window */
|
||||
void (*endpoint_reset)(struct usb_hcd *hcd,
|
||||
struct usb_host_endpoint *ep);
|
||||
|
||||
/* root hub support */
|
||||
int (*hub_status_data) (struct usb_hcd *hcd, char *buf);
|
||||
int (*hub_control) (struct usb_hcd *hcd,
|
||||
u16 typeReq, u16 wValue, u16 wIndex,
|
||||
char *buf, u16 wLength);
|
||||
#if 0
|
||||
int (*bus_suspend)(struct usb_hcd *);
|
||||
int (*bus_resume)(struct usb_hcd *);
|
||||
int (*start_port_reset)(struct usb_hcd *, unsigned port_num);
|
||||
|
||||
/* force handover of high-speed port to full-speed companion */
|
||||
void (*relinquish_port)(struct usb_hcd *, int);
|
||||
/* has a port been handed over to a companion? */
|
||||
int (*port_handed_over)(struct usb_hcd *, int);
|
||||
|
||||
/* CLEAR_TT_BUFFER completion callback */
|
||||
void (*clear_tt_buffer_complete)(struct usb_hcd *,
|
||||
struct usb_host_endpoint *);
|
||||
|
||||
/* xHCI specific functions */
|
||||
/* Called by usb_alloc_dev to alloc HC device structures */
|
||||
int (*alloc_dev)(struct usb_hcd *, struct usb_device *);
|
||||
/* Called by usb_disconnect to free HC device structures */
|
||||
void (*free_dev)(struct usb_hcd *, struct usb_device *);
|
||||
/* Change a group of bulk endpoints to support multiple stream IDs */
|
||||
int (*alloc_streams)(struct usb_hcd *hcd, struct usb_device *udev,
|
||||
struct usb_host_endpoint **eps, unsigned int num_eps,
|
||||
unsigned int num_streams, gfp_t mem_flags);
|
||||
/* Reverts a group of bulk endpoints back to not using stream IDs.
|
||||
* Can fail if we run out of memory.
|
||||
*/
|
||||
int (*free_streams)(struct usb_hcd *hcd, struct usb_device *udev,
|
||||
struct usb_host_endpoint **eps, unsigned int num_eps,
|
||||
gfp_t mem_flags);
|
||||
|
||||
/* Bandwidth computation functions */
|
||||
/* Note that add_endpoint() can only be called once per endpoint before
|
||||
* check_bandwidth() or reset_bandwidth() must be called.
|
||||
* drop_endpoint() can only be called once per endpoint also.
|
||||
* A call to xhci_drop_endpoint() followed by a call to
|
||||
* xhci_add_endpoint() will add the endpoint to the schedule with
|
||||
* possibly new parameters denoted by a different endpoint descriptor
|
||||
* in usb_host_endpoint. A call to xhci_add_endpoint() followed by a
|
||||
* call to xhci_drop_endpoint() is not allowed.
|
||||
*/
|
||||
/* Allocate endpoint resources and add them to a new schedule */
|
||||
int (*add_endpoint)(struct usb_hcd *, struct usb_device *,
|
||||
struct usb_host_endpoint *);
|
||||
/* Drop an endpoint from a new schedule */
|
||||
int (*drop_endpoint)(struct usb_hcd *, struct usb_device *,
|
||||
struct usb_host_endpoint *);
|
||||
/* Check that a new hardware configuration, set using
|
||||
* endpoint_enable and endpoint_disable, does not exceed bus
|
||||
* bandwidth. This must be called before any set configuration
|
||||
* or set interface requests are sent to the device.
|
||||
*/
|
||||
int (*check_bandwidth)(struct usb_hcd *, struct usb_device *);
|
||||
/* Reset the device schedule to the last known good schedule,
|
||||
* which was set from a previous successful call to
|
||||
* check_bandwidth(). This reverts any add_endpoint() and
|
||||
* drop_endpoint() calls since that last successful call.
|
||||
* Used for when a check_bandwidth() call fails due to resource
|
||||
* or bandwidth constraints.
|
||||
*/
|
||||
void (*reset_bandwidth)(struct usb_hcd *, struct usb_device *);
|
||||
/* Returns the hardware-chosen device address */
|
||||
int (*address_device)(struct usb_hcd *, struct usb_device *udev);
|
||||
/* Notifies the HCD after a hub descriptor is fetched.
|
||||
* Will block.
|
||||
*/
|
||||
int (*update_hub_device)(struct usb_hcd *, struct usb_device *hdev,
|
||||
struct usb_tt *tt, gfp_t mem_flags);
|
||||
int (*reset_device)(struct usb_hcd *, struct usb_device *);
|
||||
/* Notifies the HCD after a device is connected and its
|
||||
* address is set
|
||||
*/
|
||||
int (*update_device)(struct usb_hcd *, struct usb_device *);
|
||||
int (*set_usb2_hw_lpm)(struct usb_hcd *, struct usb_device *, int);
|
||||
/* USB 3.0 Link Power Management */
|
||||
/* Returns the USB3 hub-encoded value for the U1/U2 timeout. */
|
||||
int (*enable_usb3_lpm_timeout)(struct usb_hcd *,
|
||||
struct usb_device *, enum usb3_link_state state);
|
||||
/* The xHCI host controller can still fail the command to
|
||||
* disable the LPM timeouts, so this can return an error code.
|
||||
*/
|
||||
int (*disable_usb3_lpm_timeout)(struct usb_hcd *,
|
||||
struct usb_device *, enum usb3_link_state state);
|
||||
int (*find_raw_port_number)(struct usb_hcd *, int);
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -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.
|
||||
*/
|
||||
|
||||
#ifndef _RTL8195A_OTG_H_
|
||||
#define _RTL8195A_OTG_H_
|
||||
|
||||
#include "rtl8195a.h"
|
||||
#define OTG_FAST_INIT 1
|
||||
|
||||
#define HAL_OTG_READ32(addr) HAL_READ32(USB_OTG_REG_BASE, (u32)addr)
|
||||
#define HAL_OTG_WRITE32(addr, value) HAL_WRITE32(USB_OTG_REG_BASE, (u32)addr, value)
|
||||
|
||||
#define HAL_OTG_MODIFY32(addr, clrmsk, setmsk) HAL_WRITE32(USB_OTG_REG_BASE,(u32)addr,\
|
||||
((HAL_READ32(USB_OTG_REG_BASE, (u32)addr) & (~clrmsk)) | setmsk))
|
||||
|
||||
#define DWC_READ_REG32(_reg_) HAL_OTG_READ32((u32)_reg_)
|
||||
#define DWC_WRITE_REG32(_reg_, _val_) HAL_OTG_WRITE32((u32)_reg_,_val_)
|
||||
#define DWC_MODIFY_REG32(_reg_,_cmsk_,_smsk_) HAL_OTG_MODIFY32((u32)_reg_,_cmsk_,_smsk_)
|
||||
|
||||
|
||||
//This part is added for RTK power sequence
|
||||
|
||||
//3 SYS_ON reg
|
||||
|
||||
//#define REG_SYS_FUNC_EN 0x08
|
||||
#define BIT_SHIFT_SOC_SYSPEON_EN 4
|
||||
#define BIT_MASK_SOC_SYSPEON_EN 0x1
|
||||
#define BIT_SOC_SYSPEON_EN_OTG(x)(((x) & BIT_MASK_SOC_SYSPEON_EN) << BIT_SHIFT_SOC_SYSPEON_EN)
|
||||
#define BIT_INVC_SOC_SYSPEON_EN (~(BIT_MASK_SOC_SYSPEON_EN << BIT_SHIFT_SOC_SYSPEON_EN))
|
||||
|
||||
|
||||
//3 Peri_ON reg
|
||||
#define REG_OTG_PWCSEQ_OFFSET_OTG 0x40000000
|
||||
#define REG_OTG_PWCSEQ_PWC_OTG 0x200
|
||||
#define REG_OTG_PWCSEQ_ISO_OTG 0x204
|
||||
#define REG_SOC_HCI_COM_FUNC_EN_OTG 0x214
|
||||
#define REG_PESOC_HCI_CLK_CTRL0_OTG 0x240
|
||||
|
||||
//#define REG_PON_ISO_CTRL 0x204
|
||||
|
||||
|
||||
#define REG_OTG_PWCSEQ_IP_OFF 0x30004 //This is in OTG IP
|
||||
#define REG_OTG_PS_INTR_STS 0x30008 //This is in OTG IP
|
||||
#define REG_OTG_PS_INTR_MSK 0x3000C //This is in OTG IP
|
||||
|
||||
|
||||
//4 REG_OTG_PWCSEQ_PWC
|
||||
#define BIT_SHIFT_PWC_USBD_EN 0
|
||||
#define BIT_MASK_PWC_USBD_EN 0x1
|
||||
#define BIT_PWC_USBD_EN(x)(((x) & BIT_MASK_PWC_USBD_EN) << BIT_SHIFT_PWC_USBD_EN)
|
||||
#define BIT_INVC_PWC_USBD_EN (~(BIT_MASK_PWC_USBD_EN << BIT_SHIFT_PWC_USBD_EN))
|
||||
|
||||
#define BIT_SHIFT_PWC_UPLV_EN 1
|
||||
#define BIT_MASK_PWC_UPLV_EN 0x1
|
||||
#define BIT_PWC_UPLV_EN(x)(((x) & BIT_MASK_PWC_UPLV_EN) << BIT_SHIFT_PWC_UPLV_EN)
|
||||
#define BIT_INVC_PWC_UPLV_EN (~(BIT_MASK_PWC_UPLV_EN << BIT_SHIFT_PWC_UPLV_EN))
|
||||
|
||||
#define BIT_SHIFT_PWC_UPHV_EN 2
|
||||
#define BIT_MASK_PWC_UPHV_EN 0x1
|
||||
#define BIT_PWC_UPHV_EN(x)(((x) & BIT_MASK_PWC_UPHV_EN) << BIT_SHIFT_PWC_UPHV_EN)
|
||||
#define BIT_INVC_PWC_UPHV_EN (~(BIT_MASK_PWC_UPHV_EN << BIT_SHIFT_PWC_UPHV_EN))
|
||||
|
||||
//4 REG_OTG_PWCSEQ_ISO
|
||||
#define BIT_SHIFT_ISO_USBD_EN 0
|
||||
#define BIT_MASK_ISO_USBD_EN 0x1
|
||||
#define BIT_ISO_USBD_EN(x)(((x) & BIT_MASK_ISO_USBD_EN) << BIT_SHIFT_ISO_USBD_EN)
|
||||
#define BIT_INVC_ISO_USBD_EN (~(BIT_MASK_ISO_USBD_EN << BIT_SHIFT_ISO_USBD_EN))
|
||||
|
||||
#define BIT_SHIFT_ISO_USBA_EN 1
|
||||
#define BIT_MASK_ISO_USBA_EN 0x1
|
||||
#define BIT_ISO_USBA_EN(x)(((x) & BIT_MASK_ISO_USBA_EN) << BIT_SHIFT_ISO_USBA_EN)
|
||||
#define BIT_INVC_ISO_USBA_EN (~(BIT_MASK_ISO_USBA_EN << BIT_SHIFT_ISO_USBA_EN))
|
||||
|
||||
//4 REG_SOC_HCI_COM_FUNC_EN
|
||||
#define BIT_SHIFT_SOC_HCI_OTG_EN 4
|
||||
#define BIT_MASK_SOC_HCI_OTG_EN 0x1
|
||||
#define BIT_SOC_HCI_OTG_EN_OTG(x)(((x) & BIT_MASK_SOC_HCI_OTG_EN) << BIT_SHIFT_SOC_HCI_OTG_EN)
|
||||
#define BIT_INVC_SOC_HCI_OTG_EN (~(BIT_MASK_SOC_HCI_OTG_EN << BIT_SHIFT_SOC_HCI_OTG_EN))
|
||||
|
||||
//4 REG_PESOC_HCI_CLK_CTRL0
|
||||
#define BIT_SHIFT_SOC_ACTCK_OTG_EN 4
|
||||
#define BIT_MASK_SOC_ACTCK_OTG_EN 0x1
|
||||
#define BIT_SOC_ACTCK_OTG_EN_OTG(x)(((x) & BIT_MASK_SOC_ACTCK_OTG_EN) << BIT_SHIFT_SOC_ACTCK_OTG_EN)
|
||||
#define BIT_INVC_SOC_ACTCK_OTG_EN (~(BIT_MASK_SOC_ACTCK_OTG_EN << BIT_SHIFT_SOC_ACTCK_OTG_EN))
|
||||
|
||||
|
||||
//4 REG_OTG_PWCSEQ_OTG
|
||||
#define BIT_SHIFT_USBOTG_PS_EN 0
|
||||
#define BIT_MASK_USBOTG_PS_EN 0x1
|
||||
#define BIT_USBOTG_PS_EN(x)(((x) & BIT_MASK_USBOTG_PS_EN) << BIT_SHIFT_USBOTG_PS_EN)
|
||||
#define BIT_INVC_USBOTG_PS_EN (~(BIT_MASK_USBOTG_PS_EN << BIT_SHIFT_USBOTG_PS_EN))
|
||||
|
||||
#define BIT_SHIFT_USBOTG_DIS_SUSB 1
|
||||
#define BIT_MASK_USBOTG_DIS_SUSB 0x1
|
||||
#define BIT_USBOTG_DIS_SUSB(x)(((x) & BIT_MASK_USBOTG_DIS_SUSB) << BIT_SHIFT_USBOTG_DIS_SUSB)
|
||||
#define BIT_INVC_USBOTG_DIS_SUSB (~(BIT_MASK_USBOTG_DIS_SUSB << BIT_SHIFT_USBOTG_DIS_SUSB))
|
||||
|
||||
#define BIT_SHIFT_USBOTG_SUSBM 4
|
||||
#define BIT_MASK_USBOTG_SUSBM 0x1
|
||||
#define BIT_USBOTG_SUSBM(x)(((x) & BIT_MASK_USBOTG_SUSBM) << BIT_SHIFT_USBOTG_SUSBM)
|
||||
#define BIT_INVC_USBOTG_SUSBM (~(BIT_MASK_USBOTG_SUSBM << BIT_SHIFT_USBOTG_SUSBM))
|
||||
|
||||
#define BIT_SHIFT_UPLL_CKRDY 5
|
||||
#define BIT_MASK_UPLL_CKRDY 0x1
|
||||
#define BIT_UPLL_CKRDY(x)(((x) & BIT_MASK_UPLL_CKRDY) << BIT_SHIFT_UPLL_CKRDY)
|
||||
#define BIT_INVC_UPLL_CKRDY (~(BIT_MASK_UPLL_CKRDY << BIT_SHIFT_UPLL_CKRDY))
|
||||
|
||||
#define BIT_SHIFT_USB_LS 6
|
||||
#define BIT_MASK_USB_LS 0x3
|
||||
#define BIT_USB_LS(x)(((x) & BIT_MASK_USB_LS) << BIT_SHIFT_USB_LS)
|
||||
#define BIT_INVC_USB_LS (~(BIT_MASK_USB_LS << BIT_SHIFT_USB_LS))
|
||||
|
||||
#define BIT_SHIFT_USBOTG_EN 8
|
||||
#define BIT_MASK_USBOTG_EN 0x1
|
||||
#define BIT_USBOTG_EN(x)(((x) & BIT_MASK_USBOTG_EN) << BIT_SHIFT_USBOTG_EN)
|
||||
#define BIT_INVC_USBOTG_EN (~(BIT_MASK_USBOTG_EN << BIT_SHIFT_USBOTG_EN))
|
||||
|
||||
#define BIT_SHIFT_USBPHY_EN 9
|
||||
#define BIT_MASK_USBPHY_EN 0x1
|
||||
#define BIT_USBPHY_EN(x)(((x) & BIT_MASK_USBPHY_EN) << BIT_SHIFT_USBPHY_EN)
|
||||
#define BIT_INVC_USBPHY_EN (~(BIT_MASK_USBPHY_EN << BIT_SHIFT_USBPHY_EN))
|
||||
|
||||
#define BIT_SHIFT_USB_GT_LS_EN 10
|
||||
#define BIT_MASK_USB_GT_LS_EN 0x1
|
||||
#define BIT_USB_GT_LS_EN(x)(((x) & BIT_MASK_USB_GT_LS_EN) << BIT_SHIFT_USB_GT_LS_EN)
|
||||
#define BIT_INVC_USB_GT_LS_EN (~(BIT_MASK_USB_GT_LS_EN << BIT_SHIFT_USB_GT_LS_EN))
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,563 @@
|
|||
/*
|
||||
* This file holds USB constants and structures that are needed for USB
|
||||
* device APIs. These are used by the USB device model, which is defined
|
||||
* in chapter 9 of the USB 2.0 specification. Linux has several APIs in C
|
||||
* that need these:
|
||||
*
|
||||
* - the master/host side Linux-USB kernel driver API;
|
||||
* - the "usbfs" user space API; and
|
||||
* - the Linux "gadget" slave/device/peripheral side driver API.
|
||||
*
|
||||
* USB 2.0 adds an additional "On The Go" (OTG) mode, which lets systems
|
||||
* act either as a USB master/host or as a USB slave/device. That means
|
||||
* the master and slave side APIs benefit from working well together.
|
||||
*
|
||||
* There's also "Wireless USB", using low power short range radios for
|
||||
* peripheral interconnection but otherwise building on the USB framework.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _USB_CH9_H_
|
||||
#define _USB_CH9_H_
|
||||
|
||||
#include "basic_types.h"
|
||||
//#include <linux/types.h> /* __u8 etc */
|
||||
//#include "../otg/osk/sys-support.h"
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* CONTROL REQUEST SUPPORT */
|
||||
|
||||
/*
|
||||
* USB directions
|
||||
*
|
||||
* This bit flag is used in endpoint descriptors' bEndpointAddress field.
|
||||
* It's also one of three fields in control requests bRequestType.
|
||||
*/
|
||||
//#define USB_DIR_OUT 0 /* to device */
|
||||
//#define USB_DIR_IN 0x80 /* to host */
|
||||
|
||||
/*
|
||||
* USB types, the second of three bRequestType fields
|
||||
*/
|
||||
#define USB_TYPE_MASK (0x03 << 5)
|
||||
#define USB_TYPE_STANDARD (0x00 << 5)
|
||||
#define USB_TYPE_CLASS (0x01 << 5)
|
||||
#define USB_TYPE_VENDOR (0x02 << 5)
|
||||
#define USB_TYPE_RESERVED (0x03 << 5)
|
||||
|
||||
/*
|
||||
* USB recipients, the third of three bRequestType fields
|
||||
*/
|
||||
#define USB_RECIP_MASK 0x1f
|
||||
#define USB_RECIP_DEVICE 0x00
|
||||
#define USB_RECIP_INTERFACE 0x01
|
||||
#define USB_RECIP_ENDPOINT 0x02
|
||||
#define USB_RECIP_OTHER 0x03
|
||||
/* From Wireless USB 1.0 */
|
||||
#define USB_RECIP_PORT 0x04
|
||||
#define USB_RECIP_RPIPE 0x05
|
||||
|
||||
/*
|
||||
* Standard requests, for the bRequest field of a SETUP packet.
|
||||
*
|
||||
* These are qualified by the bRequestType field, so that for example
|
||||
* TYPE_CLASS or TYPE_VENDOR specific feature flags could be retrieved
|
||||
* by a GET_STATUS request.
|
||||
*/
|
||||
#define USB_REQ_GET_STATUS 0x00
|
||||
#define USB_REQ_CLEAR_FEATURE 0x01
|
||||
#define USB_REQ_SET_FEATURE 0x03
|
||||
#define USB_REQ_SET_ADDRESS 0x05
|
||||
#define USB_REQ_GET_DESCRIPTOR 0x06
|
||||
#define USB_REQ_SET_DESCRIPTOR 0x07
|
||||
#define USB_REQ_GET_CONFIGURATION 0x08
|
||||
#define USB_REQ_SET_CONFIGURATION 0x09
|
||||
#define USB_REQ_GET_INTERFACE 0x0A
|
||||
#define USB_REQ_SET_INTERFACE 0x0B
|
||||
#define USB_REQ_SYNCH_FRAME 0x0C
|
||||
|
||||
#define USB_REQ_SET_ENCRYPTION 0x0D /* Wireless USB */
|
||||
#define USB_REQ_GET_ENCRYPTION 0x0E
|
||||
#define USB_REQ_RPIPE_ABORT 0x0E
|
||||
#define USB_REQ_SET_HANDSHAKE 0x0F
|
||||
#define USB_REQ_RPIPE_RESET 0x0F
|
||||
#define USB_REQ_GET_HANDSHAKE 0x10
|
||||
#define USB_REQ_SET_CONNECTION 0x11
|
||||
#define USB_REQ_SET_SECURITY_DATA 0x12
|
||||
#define USB_REQ_GET_SECURITY_DATA 0x13
|
||||
#define USB_REQ_SET_WUSB_DATA 0x14
|
||||
#define USB_REQ_LOOPBACK_DATA_WRITE 0x15
|
||||
#define USB_REQ_LOOPBACK_DATA_READ 0x16
|
||||
#define USB_REQ_SET_INTERFACE_DS 0x17
|
||||
|
||||
/*
|
||||
* USB feature flags are written using USB_REQ_{CLEAR,SET}_FEATURE, and
|
||||
* are read as a bit array returned by USB_REQ_GET_STATUS. (So there
|
||||
* are at most sixteen features of each type.)
|
||||
*/
|
||||
#define USB_DEVICE_SELF_POWERED 0 /* (read only) */
|
||||
#define USB_DEVICE_REMOTE_WAKEUP 1 /* dev may initiate wakeup */
|
||||
#define USB_DEVICE_TEST_MODE 2 /* (wired high speed only) */
|
||||
#define USB_DEVICE_BATTERY 2 /* (wireless) */
|
||||
#define USB_DEVICE_B_HNP_ENABLE 3 /* (otg) dev may initiate HNP */
|
||||
#define USB_DEVICE_WUSB_DEVICE 3 /* (wireless)*/
|
||||
#define USB_DEVICE_A_HNP_SUPPORT 4 /* (otg) RH port supports HNP */
|
||||
#define USB_DEVICE_A_ALT_HNP_SUPPORT 5 /* (otg) other RH port does */
|
||||
#define USB_DEVICE_DEBUG_MODE 6 /* (special devices only) */
|
||||
|
||||
#define USB_ENDPOINT_HALT 0 /* IN/OUT will STALL */
|
||||
|
||||
|
||||
/**
|
||||
* struct usb_ctrlrequest - SETUP data for a USB device control request
|
||||
* @bRequestType: matches the USB bmRequestType field
|
||||
* @bRequest: matches the USB bRequest field
|
||||
* @wValue: matches the USB wValue field (le16 byte order)
|
||||
* @wIndex: matches the USB wIndex field (le16 byte order)
|
||||
* @wLength: matches the USB wLength field (le16 byte order)
|
||||
*
|
||||
* This structure is used to send control requests to a USB device. It matches
|
||||
* the different fields of the USB 2.0 Spec section 9.3, table 9-2. See the
|
||||
* USB spec for a fuller description of the different fields, and what they are
|
||||
* used for.
|
||||
*
|
||||
* Note that the driver for any interface can issue control requests.
|
||||
* For most devices, interfaces don't coordinate with each other, so
|
||||
* such requests may be made at any time.
|
||||
*/
|
||||
struct usb_ctrlrequest {
|
||||
u8 bRequestType;
|
||||
u8 bRequest;
|
||||
u16 wValue;
|
||||
u16 wIndex;
|
||||
u16 wLength;
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* STANDARD DESCRIPTORS ... as returned by GET_DESCRIPTOR, or
|
||||
* (rarely) accepted by SET_DESCRIPTOR.
|
||||
*
|
||||
* Note that all multi-byte values here are encoded in little endian
|
||||
* byte order "on the wire". But when exposed through Linux-USB APIs,
|
||||
* they've been converted to cpu byte order.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Descriptor types ... USB 2.0 spec table 9.5
|
||||
*/
|
||||
#define USB_DT_DEVICE 0x01
|
||||
#define USB_DT_CONFIG 0x02
|
||||
#define USB_DT_STRING 0x03
|
||||
#define USB_DT_INTERFACE 0x04
|
||||
#define USB_DT_ENDPOINT 0x05
|
||||
#define USB_DT_DEVICE_QUALIFIER 0x06
|
||||
#define USB_DT_OTHER_SPEED_CONFIG 0x07
|
||||
#define USB_DT_INTERFACE_POWER 0x08
|
||||
/* these are from a minor usb 2.0 revision (ECN) */
|
||||
#define USB_DT_OTG 0x09
|
||||
#define USB_DT_DEBUG 0x0a
|
||||
#define USB_DT_INTERFACE_ASSOCIATION 0x0b
|
||||
/* these are from the Wireless USB spec */
|
||||
#define USB_DT_SECURITY 0x0c
|
||||
#define USB_DT_KEY 0x0d
|
||||
#define USB_DT_ENCRYPTION_TYPE 0x0e
|
||||
#define USB_DT_BOS 0x0f
|
||||
#define USB_DT_DEVICE_CAPABILITY 0x10
|
||||
#define USB_DT_WIRELESS_ENDPOINT_COMP 0x11
|
||||
#define USB_DT_WIRE_ADAPTER 0x21
|
||||
#define USB_DT_RPIPE 0x22
|
||||
|
||||
/* conventional codes for class-specific descriptors */
|
||||
#define USB_DT_CS_DEVICE 0x21
|
||||
#define USB_DT_CS_CONFIG 0x22
|
||||
#define USB_DT_CS_STRING 0x23
|
||||
#define USB_DT_CS_INTERFACE 0x24
|
||||
#define USB_DT_CS_ENDPOINT 0x25
|
||||
|
||||
/* All standard descriptors have these 2 fields at the beginning */
|
||||
struct usb_descriptor_header {
|
||||
u8 bLength;
|
||||
u8 bDescriptorType;
|
||||
};
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_DEVICE: Device descriptor */
|
||||
struct usb_device_descriptor {
|
||||
u8 bLength;
|
||||
u8 bDescriptorType;
|
||||
|
||||
u16 bcdUSB;
|
||||
u8 bDeviceClass;
|
||||
u8 bDeviceSubClass;
|
||||
u8 bDeviceProtocol;
|
||||
u8 bMaxPacketSize0;
|
||||
u16 idVendor;
|
||||
u16 idProduct;
|
||||
u16 bcdDevice;
|
||||
u8 iManufacturer;
|
||||
u8 iProduct;
|
||||
u8 iSerialNumber;
|
||||
u8 bNumConfigurations;
|
||||
};
|
||||
|
||||
#define USB_DT_DEVICE_SIZE 18
|
||||
|
||||
|
||||
/*
|
||||
* Device and/or Interface Class codes
|
||||
* as found in bDeviceClass or bInterfaceClass
|
||||
* and defined by www.usb.org documents
|
||||
*/
|
||||
#define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */
|
||||
#define USB_CLASS_AUDIO 1
|
||||
#define USB_CLASS_COMM 2
|
||||
#define USB_CLASS_HID 3
|
||||
#define USB_CLASS_PHYSICAL 5
|
||||
#define USB_CLASS_STILL_IMAGE 6
|
||||
#define USB_CLASS_PRINTER 7
|
||||
#define USB_CLASS_MASS_STORAGE 8
|
||||
#define USB_CLASS_HUB 9
|
||||
#define USB_CLASS_CDC_DATA 0x0a
|
||||
#define USB_CLASS_CSCID 0x0b /* chip+ smart card */
|
||||
#define USB_CLASS_CONTENT_SEC 0x0d /* content security */
|
||||
#define USB_CLASS_VIDEO 0x0e
|
||||
#define USB_CLASS_WIRELESS_CONTROLLER 0xe0
|
||||
#define USB_CLASS_APP_SPEC 0xfe
|
||||
#define USB_CLASS_VENDOR_SPEC 0xff
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_CONFIG: Configuration descriptor information.
|
||||
*
|
||||
* USB_DT_OTHER_SPEED_CONFIG is the same descriptor, except that the
|
||||
* descriptor type is different. Highspeed-capable devices can look
|
||||
* different depending on what speed they're currently running. Only
|
||||
* devices with a USB_DT_DEVICE_QUALIFIER have any OTHER_SPEED_CONFIG
|
||||
* descriptors.
|
||||
*/
|
||||
struct usb_config_descriptor {
|
||||
u8 bLength;
|
||||
u8 bDescriptorType;
|
||||
|
||||
u16 wTotalLength;
|
||||
u8 bNumInterfaces;
|
||||
u8 bConfigurationValue;
|
||||
u8 iConfiguration;
|
||||
u8 bmAttributes;
|
||||
u8 bMaxPower;
|
||||
};
|
||||
|
||||
#define USB_DT_CONFIG_SIZE 9
|
||||
|
||||
/* from config descriptor bmAttributes */
|
||||
#define USB_CONFIG_ATT_ONE (1 << 7) /* must be set */
|
||||
#define USB_CONFIG_ATT_SELFPOWER (1 << 6) /* self powered */
|
||||
#define USB_CONFIG_ATT_WAKEUP (1 << 5) /* can wakeup */
|
||||
#define USB_CONFIG_ATT_BATTERY (1 << 4) /* battery powered */
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_STRING: String descriptor */
|
||||
struct usb_string_descriptor {
|
||||
u8 bLength;
|
||||
u8 bDescriptorType;
|
||||
|
||||
u16 wData[1]; /* UTF-16LE encoded */
|
||||
};
|
||||
|
||||
/* note that "string" zero is special, it holds language codes that
|
||||
* the device supports, not Unicode characters.
|
||||
*/
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_INTERFACE: Interface descriptor */
|
||||
struct usb_interface_descriptor {
|
||||
u8 bLength;
|
||||
u8 bDescriptorType;
|
||||
|
||||
u8 bInterfaceNumber;
|
||||
u8 bAlternateSetting;
|
||||
u8 bNumEndpoints;
|
||||
u8 bInterfaceClass;
|
||||
u8 bInterfaceSubClass;
|
||||
u8 bInterfaceProtocol;
|
||||
u8 iInterface;
|
||||
};
|
||||
|
||||
#define USB_DT_INTERFACE_SIZE 9
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* Endpoint descriptor */
|
||||
struct usb_endpoint_descriptor {
|
||||
u8 bLength;
|
||||
u8 bDescriptorType;
|
||||
u8 bEndpointAddress;
|
||||
u8 bmAttributes;
|
||||
u16 wMaxPacketSize;
|
||||
u8 bInterval;
|
||||
u8 bRefresh;
|
||||
u8 bSynchAddress;
|
||||
|
||||
unsigned char *extra; /* Extra descriptors */
|
||||
int extralen;
|
||||
};
|
||||
|
||||
#define USB_DT_ENDPOINT_SIZE 7
|
||||
#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */
|
||||
|
||||
|
||||
/*
|
||||
* Endpoints
|
||||
*/
|
||||
#if 0
|
||||
#define USB_ENDPOINT_NUMBER_MASK 0x0f /* in bEndpointAddress */
|
||||
#define USB_ENDPOINT_DIR_MASK 0x80
|
||||
|
||||
#define USB_ENDPOINT_XFERTYPE_MASK 0x03 /* in bmAttributes */
|
||||
#define USB_ENDPOINT_XFER_CONTROL 0
|
||||
#define USB_ENDPOINT_XFER_ISOC 1
|
||||
#define USB_ENDPOINT_XFER_BULK 2
|
||||
#define USB_ENDPOINT_XFER_INT 3
|
||||
#define USB_ENDPOINT_MAX_ADJUSTABLE 0x80
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_DEVICE_QUALIFIER: Device Qualifier descriptor */
|
||||
struct usb_qualifier_descriptor {
|
||||
u8 bLength;
|
||||
u8 bDescriptorType;
|
||||
|
||||
u16 bcdUSB;
|
||||
u8 bDeviceClass;
|
||||
u8 bDeviceSubClass;
|
||||
u8 bDeviceProtocol;
|
||||
u8 bMaxPacketSize0;
|
||||
u8 bNumConfigurations;
|
||||
u8 bRESERVED;
|
||||
};
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_OTG (from OTG 1.0a supplement) */
|
||||
struct usb_otg_descriptor {
|
||||
u8 bLength;
|
||||
u8 bDescriptorType;
|
||||
|
||||
u8 bmAttributes; /* support for HNP, SRP, etc */
|
||||
};
|
||||
|
||||
/* from usb_otg_descriptor.bmAttributes */
|
||||
#define USB_OTG_SRP (1 << 0)
|
||||
#define USB_OTG_HNP (1 << 1) /* swap host/device roles */
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_DEBUG: for special highspeed devices, replacing serial console */
|
||||
struct usb_debug_descriptor {
|
||||
u8 bLength;
|
||||
u8 bDescriptorType;
|
||||
|
||||
/* bulk endpoints with 8 byte maxpacket */
|
||||
u8 bDebugInEndpoint;
|
||||
u8 bDebugOutEndpoint;
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_INTERFACE_ASSOCIATION: groups interfaces */
|
||||
struct usb_interface_assoc_descriptor {
|
||||
u8 bLength;
|
||||
u8 bDescriptorType;
|
||||
|
||||
u8 bFirstInterface;
|
||||
u8 bInterfaceCount;
|
||||
u8 bFunctionClass;
|
||||
u8 bFunctionSubClass;
|
||||
u8 bFunctionProtocol;
|
||||
u8 iFunction;
|
||||
};
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_SECURITY: group of wireless security descriptors, including
|
||||
* encryption types available for setting up a CC/association.
|
||||
*/
|
||||
struct usb_security_descriptor {
|
||||
u8 bLength;
|
||||
u8 bDescriptorType;
|
||||
|
||||
u16 wTotalLength;
|
||||
u8 bNumEncryptionTypes;
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_KEY: used with {GET,SET}_SECURITY_DATA; only public keys
|
||||
* may be retrieved.
|
||||
*/
|
||||
struct usb_key_descriptor {
|
||||
u8 bLength;
|
||||
u8 bDescriptorType;
|
||||
|
||||
u8 tTKID[3];
|
||||
u8 bReserved;
|
||||
u8 bKeyData[0];
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_ENCRYPTION_TYPE: bundled in DT_SECURITY groups */
|
||||
struct usb_encryption_descriptor {
|
||||
u8 bLength;
|
||||
u8 bDescriptorType;
|
||||
|
||||
u8 bEncryptionType;
|
||||
#define USB_ENC_TYPE_UNSECURE 0
|
||||
#define USB_ENC_TYPE_WIRED 1 /* non-wireless mode */
|
||||
#define USB_ENC_TYPE_CCM_1 2 /* aes128/cbc session */
|
||||
#define USB_ENC_TYPE_RSA_1 3 /* rsa3072/sha1 auth */
|
||||
u8 bEncryptionValue; /* use in SET_ENCRYPTION */
|
||||
u8 bAuthKeyIndex;
|
||||
};
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_BOS: group of wireless capabilities */
|
||||
struct usb_bos_descriptor {
|
||||
u8 bLength;
|
||||
u8 bDescriptorType;
|
||||
|
||||
u16 wTotalLength;
|
||||
u8 bNumDeviceCaps;
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_DEVICE_CAPABILITY: grouped with BOS */
|
||||
struct usb_dev_cap_header {
|
||||
u8 bLength;
|
||||
u8 bDescriptorType;
|
||||
u8 bDevCapabilityType;
|
||||
};
|
||||
|
||||
#define USB_CAP_TYPE_WIRELESS_USB 1
|
||||
|
||||
struct usb_wireless_cap_descriptor { /* Ultra Wide Band */
|
||||
u8 bLength;
|
||||
u8 bDescriptorType;
|
||||
u8 bDevCapabilityType;
|
||||
|
||||
u8 bmAttributes;
|
||||
#define USB_WIRELESS_P2P_DRD (1 << 1)
|
||||
#define USB_WIRELESS_BEACON_MASK (3 << 2)
|
||||
#define USB_WIRELESS_BEACON_SELF (1 << 2)
|
||||
#define USB_WIRELESS_BEACON_DIRECTED (2 << 2)
|
||||
#define USB_WIRELESS_BEACON_NONE (3 << 2)
|
||||
u16 wPHYRates; /* bit rates, Mbps */
|
||||
#define USB_WIRELESS_PHY_53 (1 << 0) /* always set */
|
||||
#define USB_WIRELESS_PHY_80 (1 << 1)
|
||||
#define USB_WIRELESS_PHY_107 (1 << 2) /* always set */
|
||||
#define USB_WIRELESS_PHY_160 (1 << 3)
|
||||
#define USB_WIRELESS_PHY_200 (1 << 4) /* always set */
|
||||
#define USB_WIRELESS_PHY_320 (1 << 5)
|
||||
#define USB_WIRELESS_PHY_400 (1 << 6)
|
||||
#define USB_WIRELESS_PHY_480 (1 << 7)
|
||||
u8 bmTFITXPowerInfo; /* TFI power levels */
|
||||
u8 bmFFITXPowerInfo; /* FFI power levels */
|
||||
u16 bmBandGroup;
|
||||
u8 bReserved;
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_WIRELESS_ENDPOINT_COMP: companion descriptor associated with
|
||||
* each endpoint descriptor for a wireless device
|
||||
*/
|
||||
struct usb_wireless_ep_comp_descriptor {
|
||||
u8 bLength;
|
||||
u8 bDescriptorType;
|
||||
|
||||
u8 bMaxBurst;
|
||||
u8 bMaxSequence;
|
||||
u16 wMaxStreamDelay;
|
||||
u16 wOverTheAirPacketSize;
|
||||
u8 bOverTheAirInterval;
|
||||
u8 bmCompAttributes;
|
||||
#define USB_ENDPOINT_SWITCH_MASK 0x03 /* in bmCompAttributes */
|
||||
#define USB_ENDPOINT_SWITCH_NO 0
|
||||
#define USB_ENDPOINT_SWITCH_SWITCH 1
|
||||
#define USB_ENDPOINT_SWITCH_SCALE 2
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_REQ_SET_HANDSHAKE is a four-way handshake used between a wireless
|
||||
* host and a device for connection set up, mutual authentication, and
|
||||
* exchanging short lived session keys. The handshake depends on a CC.
|
||||
*/
|
||||
struct usb_handshake {
|
||||
u8 bMessageNumber;
|
||||
u8 bStatus;
|
||||
u8 tTKID[3];
|
||||
u8 bReserved;
|
||||
u8 CDID[16];
|
||||
u8 nonce[16];
|
||||
u8 MIC[8];
|
||||
};
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_REQ_SET_CONNECTION modifies or revokes a connection context (CC).
|
||||
* A CC may also be set up using non-wireless secure channels (including
|
||||
* wired USB!), and some devices may support CCs with multiple hosts.
|
||||
*/
|
||||
struct usb_connection_context {
|
||||
u8 CHID[16]; /* persistent host id */
|
||||
u8 CDID[16]; /* device id (unique w/in host context) */
|
||||
u8 CK[16]; /* connection key */
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
#if 1
|
||||
|
||||
|
||||
|
||||
|
||||
enum usb_device_state {
|
||||
/* NOTATTACHED isn't in the USB spec, and this state acts
|
||||
* the same as ATTACHED ... but it's clearer this way.
|
||||
*/
|
||||
USB_STATE_NOTATTACHED = 0,
|
||||
|
||||
/* chapter 9 and authentication (wireless) device states */
|
||||
USB_STATE_ATTACHED,
|
||||
USB_STATE_POWERED, /* wired */
|
||||
USB_STATE_UNAUTHENTICATED, /* auth */
|
||||
USB_STATE_RECONNECTING, /* auth */
|
||||
USB_STATE_DEFAULT, /* limited function */
|
||||
USB_STATE_ADDRESS,
|
||||
USB_STATE_CONFIGURED, /* most functions */
|
||||
|
||||
USB_STATE_SUSPENDED
|
||||
|
||||
/* NOTE: there are actually four different SUSPENDED
|
||||
* states, returning to POWERED, DEFAULT, ADDRESS, or
|
||||
* CONFIGURED respectively when SOF tokens flow again.
|
||||
*/
|
||||
};
|
||||
#endif
|
||||
#endif /* __LINUX_USB_CH9_H */
|
||||
|
||||
|
|
@ -0,0 +1,378 @@
|
|||
/*
|
||||
* (C) Copyright 2001
|
||||
* Denis Peter, MPL AG Switzerland
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* 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., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Note: Part of this code has been derived from linux
|
||||
*
|
||||
*/
|
||||
#ifndef _USB_DEFS_H_
|
||||
#define _USB_DEFS_H_
|
||||
/* USB constants */
|
||||
|
||||
/* Device and/or Interface Class codes */
|
||||
#define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */
|
||||
#define USB_CLASS_AUDIO 1
|
||||
#define USB_CLASS_COMM 2
|
||||
#define USB_CLASS_HID 3
|
||||
#define USB_CLASS_PHYSICAL 5
|
||||
#define USB_CLASS_STILL_IMAGE 6
|
||||
|
||||
#define USB_CLASS_PRINTER 7
|
||||
#define USB_CLASS_MASS_STORAGE 8
|
||||
#define USB_CLASS_HUB 9
|
||||
#define USB_CLASS_CDC_DATA 0x0a
|
||||
|
||||
#define USB_CLASS_DATA 10
|
||||
#define USB_CLASS_CSCID 0x0b /* chip+ smart card */
|
||||
#define USB_CLASS_CONTENT_SEC 0x0d /* content security */
|
||||
#define USB_CLASS_VIDEO 0x0e
|
||||
#define USB_CLASS_WIRELESS_CONTROLLER 0xe0
|
||||
#define USB_CLASS_APP_SPEC 0xfe
|
||||
|
||||
#define USB_CLASS_VENDOR_SPEC 0xff
|
||||
|
||||
/* some HID sub classes */
|
||||
#define USB_SUB_HID_NONE 0
|
||||
#define USB_SUB_HID_BOOT 1
|
||||
|
||||
/* some UID Protocols */
|
||||
#define USB_PROT_HID_NONE 0
|
||||
#define USB_PROT_HID_KEYBOARD 1
|
||||
#define USB_PROT_HID_MOUSE 2
|
||||
|
||||
|
||||
/* Sub STORAGE Classes */
|
||||
#define US_SC_RBC 1 /* Typically, flash devices */
|
||||
#define US_SC_8020 2 /* CD-ROM */
|
||||
#define US_SC_QIC 3 /* QIC-157 Tapes */
|
||||
#define US_SC_UFI 4 /* Floppy */
|
||||
#define US_SC_8070 5 /* Removable media */
|
||||
#define US_SC_SCSI 6 /* Transparent */
|
||||
#define US_SC_MIN US_SC_RBC
|
||||
#define US_SC_MAX US_SC_SCSI
|
||||
|
||||
/* STORAGE Protocols */
|
||||
#define US_PR_CB 1 /* Control/Bulk w/o interrupt */
|
||||
#define US_PR_CBI 0 /* Control/Bulk/Interrupt */
|
||||
#define US_PR_BULK 0x50 /* bulk only */
|
||||
|
||||
/* USB types */
|
||||
#define USB_TYPE_STANDARD (0x00 << 5)
|
||||
#define USB_TYPE_CLASS (0x01 << 5)
|
||||
#define USB_TYPE_VENDOR (0x02 << 5)
|
||||
#define USB_TYPE_RESERVED (0x03 << 5)
|
||||
|
||||
/* USB recipients */
|
||||
#define USB_RECIP_DEVICE 0x00
|
||||
#define USB_RECIP_INTERFACE 0x01
|
||||
#define USB_RECIP_ENDPOINT 0x02
|
||||
#define USB_RECIP_OTHER 0x03
|
||||
|
||||
|
||||
#define USB_DT_CS_DEVICE 0x21
|
||||
#define USB_DT_CS_CONFIG 0x22
|
||||
#define USB_DT_CS_STRING 0x23
|
||||
#define USB_DT_CS_INTERFACE 0x24
|
||||
#define USB_DT_CS_ENDPOINT 0x25
|
||||
|
||||
|
||||
/* USB directions */
|
||||
#define USB_DIR_OUT 0 /* to device */
|
||||
#define USB_DIR_IN 0x80 /* to host */
|
||||
|
||||
#if 0
|
||||
enum usb_device_speed {
|
||||
USB_SPEED_UNKNOWN = 0, /* enumerating */
|
||||
USB_SPEED_LOW,
|
||||
USB_SPEED_FULL, /* usb 1.1 */
|
||||
USB_SPEED_HIGH, /* usb 2.0 */
|
||||
};
|
||||
#else
|
||||
enum usb_device_speed {
|
||||
USB_SPEED_UNKNOWN = 0, /* enumerating */
|
||||
USB_SPEED_LOW, USB_SPEED_FULL, /* usb 1.1 */
|
||||
USB_SPEED_HIGH, /* usb 2.0 */
|
||||
USB_SPEED_VARIABLE, /* wireless (usb 2.5) */
|
||||
};
|
||||
|
||||
#endif
|
||||
/* Descriptor types */
|
||||
#define USB_DT_DEVICE 0x01
|
||||
#define USB_DT_CONFIG 0x02
|
||||
#define USB_DT_STRING 0x03
|
||||
#define USB_DT_INTERFACE 0x04
|
||||
#define USB_DT_ENDPOINT 0x05
|
||||
#define USB_DT_DEVICE_QUALIFIER 0x06
|
||||
#define USB_DT_OTHER_SPEED_CONFIG 0x07
|
||||
#define USB_DT_INTERFACE_POWER 0x08
|
||||
/* these are from a minor usb 2.0 revision (ECN) */
|
||||
#define USB_DT_OTG 0x09
|
||||
#define USB_DT_DEBUG 0x0a
|
||||
#define USB_DT_INTERFACE_ASSOCIATION 0x0b
|
||||
/* these are from the Wireless USB spec */
|
||||
#define USB_DT_SECURITY 0x0c
|
||||
#define USB_DT_KEY 0x0d
|
||||
#define USB_DT_ENCRYPTION_TYPE 0x0e
|
||||
#define USB_DT_BOS 0x0f
|
||||
#define USB_DT_DEVICE_CAPABILITY 0x10
|
||||
#define USB_DT_WIRELESS_ENDPOINT_COMP 0x11
|
||||
#define USB_DT_WIRE_ADAPTER 0x21
|
||||
#define USB_DT_RPIPE 0x22
|
||||
|
||||
//#define USB_DT_INTERFACE_ASSOCIATION 0x0b
|
||||
|
||||
#define USB_DT_HID (USB_TYPE_CLASS | 0x01)
|
||||
#define USB_DT_REPORT (USB_TYPE_CLASS | 0x02)
|
||||
#define USB_DT_PHYSICAL (USB_TYPE_CLASS | 0x03)
|
||||
#define USB_DT_HUB (USB_TYPE_CLASS | 0x09)
|
||||
|
||||
/* Descriptor sizes per descriptor type */
|
||||
#define USB_DT_DEVICE_SIZE 18
|
||||
#define USB_DT_CONFIG_SIZE 9
|
||||
#define USB_DT_INTERFACE_SIZE 9
|
||||
#define USB_DT_ENDPOINT_SIZE 7
|
||||
#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */
|
||||
#define USB_DT_HUB_NONVAR_SIZE 7
|
||||
#define USB_DT_HID_SIZE 9
|
||||
|
||||
/* Endpoints */
|
||||
#define USB_ENDPOINT_NUMBER_MASK 0x0f /* in bEndpointAddress */
|
||||
#define USB_ENDPOINT_DIR_MASK 0x80
|
||||
|
||||
#define USB_ENDPOINT_XFERTYPE_MASK 0x03 /* in bmAttributes */
|
||||
#define USB_ENDPOINT_XFER_CONTROL 0
|
||||
#define USB_ENDPOINT_XFER_ISOC 1
|
||||
#define USB_ENDPOINT_XFER_BULK 2
|
||||
#define USB_ENDPOINT_XFER_INT 3
|
||||
|
||||
#define USB_ENDPOINT_HALT 0 /* IN/OUT will STALL */
|
||||
|
||||
/* USB Packet IDs (PIDs) */
|
||||
#define USB_PID_UNDEF_0 0xf0
|
||||
#define USB_PID_OUT 0xe1
|
||||
#define USB_PID_ACK 0xd2
|
||||
#define USB_PID_DATA0 0xc3
|
||||
#define USB_PID_UNDEF_4 0xb4
|
||||
#define USB_PID_SOF 0xa5
|
||||
#define USB_PID_UNDEF_6 0x96
|
||||
#define USB_PID_UNDEF_7 0x87
|
||||
#define USB_PID_UNDEF_8 0x78
|
||||
#define USB_PID_IN 0x69
|
||||
#define USB_PID_NAK 0x5a
|
||||
#define USB_PID_DATA1 0x4b
|
||||
#define USB_PID_PREAMBLE 0x3c
|
||||
#define USB_PID_SETUP 0x2d
|
||||
#define USB_PID_STALL 0x1e
|
||||
#define USB_PID_UNDEF_F 0x0f
|
||||
|
||||
/* Standard requests */
|
||||
#define USB_REQ_GET_STATUS 0x00
|
||||
#define USB_REQ_CLEAR_FEATURE 0x01
|
||||
#define USB_REQ_SET_FEATURE 0x03
|
||||
#define USB_REQ_SET_ADDRESS 0x05
|
||||
#define USB_REQ_GET_DESCRIPTOR 0x06
|
||||
#define USB_REQ_SET_DESCRIPTOR 0x07
|
||||
#define USB_REQ_GET_CONFIGURATION 0x08
|
||||
#define USB_REQ_SET_CONFIGURATION 0x09
|
||||
#define USB_REQ_GET_INTERFACE 0x0A
|
||||
#define USB_REQ_SET_INTERFACE 0x0B
|
||||
#define USB_REQ_SYNCH_FRAME 0x0C
|
||||
|
||||
/* HID requests */
|
||||
#define USB_REQ_GET_REPORT 0x01
|
||||
#define USB_REQ_GET_IDLE 0x02
|
||||
#define USB_REQ_GET_PROTOCOL 0x03
|
||||
#define USB_REQ_SET_REPORT 0x09
|
||||
#define USB_REQ_SET_IDLE 0x0A
|
||||
#define USB_REQ_SET_PROTOCOL 0x0B
|
||||
|
||||
|
||||
/* "pipe" definitions */
|
||||
|
||||
#define PIPE_ISOCHRONOUS 0
|
||||
#define PIPE_INTERRUPT 1
|
||||
#define PIPE_CONTROL 2
|
||||
#define PIPE_BULK 3
|
||||
#define PIPE_DEVEP_MASK 0x0007ff00
|
||||
|
||||
#define USB_ISOCHRONOUS 0
|
||||
#define USB_INTERRUPT 1
|
||||
#define USB_CONTROL 2
|
||||
#define USB_BULK 3
|
||||
|
||||
/* USB-status codes: */
|
||||
#define USB_ST_ACTIVE 0x1 /* TD is active */
|
||||
#define USB_ST_STALLED 0x2 /* TD is stalled */
|
||||
#define USB_ST_BUF_ERR 0x4 /* buffer error */
|
||||
#define USB_ST_BABBLE_DET 0x8 /* Babble detected */
|
||||
#define USB_ST_NAK_REC 0x10 /* NAK Received*/
|
||||
#define USB_ST_CRC_ERR 0x20 /* CRC/timeout Error */
|
||||
#define USB_ST_BIT_ERR 0x40 /* Bitstuff error */
|
||||
#define USB_ST_NOT_PROC 0x80000000L /* Not yet processed */
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* Hub defines
|
||||
*/
|
||||
|
||||
/*
|
||||
* Hub request types
|
||||
*/
|
||||
|
||||
#define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE)
|
||||
#define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER)
|
||||
|
||||
/*
|
||||
* Hub Class feature numbers
|
||||
*/
|
||||
#define C_HUB_LOCAL_POWER 0
|
||||
#define C_HUB_OVER_CURRENT 1
|
||||
|
||||
/*
|
||||
* Port feature numbers
|
||||
*/
|
||||
#define USB_PORT_FEAT_CONNECTION 0
|
||||
#define USB_PORT_FEAT_ENABLE 1
|
||||
#define USB_PORT_FEAT_SUSPEND 2
|
||||
#define USB_PORT_FEAT_OVER_CURRENT 3
|
||||
#define USB_PORT_FEAT_RESET 4
|
||||
#define USB_PORT_FEAT_POWER 8
|
||||
#define USB_PORT_FEAT_LOWSPEED 9
|
||||
#define USB_PORT_FEAT_HIGHSPEED 10
|
||||
#define USB_PORT_FEAT_C_CONNECTION 16
|
||||
#define USB_PORT_FEAT_C_ENABLE 17
|
||||
#define USB_PORT_FEAT_C_SUSPEND 18
|
||||
#define USB_PORT_FEAT_C_OVER_CURRENT 19
|
||||
#define USB_PORT_FEAT_C_RESET 20
|
||||
|
||||
/* wPortStatus bits */
|
||||
#define USB_PORT_STAT_CONNECTION 0x0001
|
||||
#define USB_PORT_STAT_ENABLE 0x0002
|
||||
#define USB_PORT_STAT_SUSPEND 0x0004
|
||||
#define USB_PORT_STAT_OVERCURRENT 0x0008
|
||||
#define USB_PORT_STAT_RESET 0x0010
|
||||
#define USB_PORT_STAT_POWER 0x0100
|
||||
#define USB_PORT_STAT_LOW_SPEED 0x0200
|
||||
#define USB_PORT_STAT_HIGH_SPEED 0x0400 /* support for EHCI */
|
||||
#define USB_PORT_STAT_SPEED \
|
||||
(USB_PORT_STAT_LOW_SPEED | USB_PORT_STAT_HIGH_SPEED)
|
||||
|
||||
/* wPortChange bits */
|
||||
#define USB_PORT_STAT_C_CONNECTION 0x0001
|
||||
#define USB_PORT_STAT_C_ENABLE 0x0002
|
||||
#define USB_PORT_STAT_C_SUSPEND 0x0004
|
||||
#define USB_PORT_STAT_C_OVERCURRENT 0x0008
|
||||
#define USB_PORT_STAT_C_RESET 0x0010
|
||||
|
||||
/* wHubCharacteristics (masks) */
|
||||
#define HUB_CHAR_LPSM 0x0003
|
||||
#define HUB_CHAR_COMPOUND 0x0004
|
||||
#define HUB_CHAR_OCPM 0x0018
|
||||
|
||||
/*
|
||||
*Hub Status & Hub Change bit masks
|
||||
*/
|
||||
#define HUB_STATUS_LOCAL_POWER 0x0001
|
||||
#define HUB_STATUS_OVERCURRENT 0x0002
|
||||
|
||||
#define HUB_CHANGE_LOCAL_POWER 0x0001
|
||||
#define HUB_CHANGE_OVERCURRENT 0x0002
|
||||
|
||||
/* Struct USB_HCD defination */
|
||||
// for flags
|
||||
#define HCD_FLAG_HW_ACCESSIBLE 0 /* at full power */
|
||||
#define HCD_FLAG_POLL_RH 2 /* poll for rh status? */
|
||||
#define HCD_FLAG_POLL_PENDING 3 /* status has changed? */
|
||||
#define HCD_FLAG_WAKEUP_PENDING 4 /* root hub is resuming? */
|
||||
#define HCD_FLAG_RH_RUNNING 5 /* root hub is running? */
|
||||
#define HCD_FLAG_DEAD 6 /* controller has died? */
|
||||
|
||||
/* The flags can be tested using these macros; they are likely to
|
||||
* be slightly faster than test_bit().
|
||||
*/
|
||||
#define HCD_HW_ACCESSIBLE(hcd) ((hcd)->flags & (1U << HCD_FLAG_HW_ACCESSIBLE))
|
||||
#define HCD_POLL_RH(hcd) ((hcd)->flags & (1U << HCD_FLAG_POLL_RH))
|
||||
#define HCD_POLL_PENDING(hcd) ((hcd)->flags & (1U << HCD_FLAG_POLL_PENDING))
|
||||
#define HCD_WAKEUP_PENDING(hcd) ((hcd)->flags & (1U << HCD_FLAG_WAKEUP_PENDING))
|
||||
#define HCD_RH_RUNNING(hcd) ((hcd)->flags & (1U << HCD_FLAG_RH_RUNNING))
|
||||
#define HCD_DEAD(hcd) ((hcd)->flags & (1U << HCD_FLAG_DEAD))
|
||||
|
||||
// for state
|
||||
#define __ACTIVE 0x01
|
||||
#define __SUSPEND 0x04
|
||||
#define __TRANSIENT 0x80
|
||||
|
||||
#define HC_STATE_HALT 0
|
||||
#define HC_STATE_RUNNING (__ACTIVE)
|
||||
#define HC_STATE_QUIESCING (__SUSPEND|__TRANSIENT|__ACTIVE)
|
||||
#define HC_STATE_RESUMING (__SUSPEND|__TRANSIENT)
|
||||
#define HC_STATE_SUSPENDED (__SUSPEND)
|
||||
|
||||
#define HC_IS_RUNNING(state) ((state) & __ACTIVE)
|
||||
#define HC_IS_SUSPENDED(state) ((state) & __SUSPEND)
|
||||
|
||||
/*
|
||||
* USB feature flags are written using USB_REQ_{CLEAR,SET}_FEATURE, and
|
||||
* are read as a bit array returned by USB_REQ_GET_STATUS. (So there
|
||||
* are at most sixteen features of each type.) Hubs may also support a
|
||||
* new USB_REQ_TEST_AND_SET_FEATURE to put ports into L1 suspend.
|
||||
*/
|
||||
#define USB_DEVICE_SELF_POWERED 0 /* (read only) */
|
||||
#define USB_DEVICE_REMOTE_WAKEUP 1 /* dev may initiate wakeup */
|
||||
#define USB_DEVICE_TEST_MODE 2 /* (wired high speed only) */
|
||||
#define USB_DEVICE_BATTERY 2 /* (wireless) */
|
||||
#define USB_DEVICE_B_HNP_ENABLE 3 /* (otg) dev may initiate HNP */
|
||||
#define USB_DEVICE_WUSB_DEVICE 3 /* (wireless)*/
|
||||
#define USB_DEVICE_A_HNP_SUPPORT 4 /* (otg) RH port supports HNP */
|
||||
#define USB_DEVICE_A_ALT_HNP_SUPPORT 5 /* (otg) other RH port does */
|
||||
#define USB_DEVICE_DEBUG_MODE 6 /* (special devices only) */
|
||||
|
||||
/* (shifted) direction/type/recipient from the USB 2.0 spec, table 9.2 */
|
||||
#define DeviceRequest \
|
||||
((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_DEVICE)<<8)
|
||||
#define DeviceOutRequest \
|
||||
((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_DEVICE)<<8)
|
||||
|
||||
#define InterfaceRequest \
|
||||
((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8)
|
||||
|
||||
#define EndpointRequest \
|
||||
((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8)
|
||||
#define EndpointOutRequest \
|
||||
((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8)
|
||||
|
||||
/* class requests from the USB 2.0 hub spec, table 11-15 */
|
||||
/* GetBusState and SetHubDescriptor are optional, omitted */
|
||||
#define ClearHubFeature (0x2000 | USB_REQ_CLEAR_FEATURE)
|
||||
#define ClearPortFeature (0x2300 | USB_REQ_CLEAR_FEATURE)
|
||||
#define GetHubDescriptor (0xa000 | USB_REQ_GET_DESCRIPTOR)
|
||||
#define GetHubStatus (0xa000 | USB_REQ_GET_STATUS)
|
||||
#define GetPortStatus (0xa300 | USB_REQ_GET_STATUS)
|
||||
#define SetHubFeature (0x2000 | USB_REQ_SET_FEATURE)
|
||||
#define SetPortFeature (0x2300 | USB_REQ_SET_FEATURE)
|
||||
|
||||
/* from config descriptor bmAttributes */
|
||||
#define USB_CONFIG_ATT_ONE (1 << 7) /* must be set */
|
||||
#define USB_CONFIG_ATT_SELFPOWER (1 << 6) /* self powered */
|
||||
#define USB_CONFIG_ATT_WAKEUP (1 << 5) /* can wakeup */
|
||||
#define USB_CONFIG_ATT_BATTERY (1 << 4) /* battery powered */
|
||||
|
||||
#endif /*_USB_DEFS_H_ */
|
||||
|
|
@ -0,0 +1,937 @@
|
|||
/*
|
||||
* <linux/usb_gadget.h>
|
||||
*
|
||||
* We call the USB code inside a Linux-based peripheral device a "gadget"
|
||||
* driver, except for the hardware-specific bus glue. One USB host can
|
||||
* master many USB gadgets, but the gadgets are only slaved to one host.
|
||||
*
|
||||
*
|
||||
* (C) Copyright 2002-2004 by David Brownell
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This software is licensed under the GNU GPL version 2.
|
||||
*/
|
||||
|
||||
#ifndef __USB_GADGET_H
|
||||
#define __USB_GADGET_H
|
||||
|
||||
//#include "xlinux.h"
|
||||
|
||||
//#ifdef __KERNEL__
|
||||
#include "osdep_api.h"
|
||||
#include "usb_ch9.h"
|
||||
|
||||
#if 1//defined(CONFIG_RTL_ULINKER)
|
||||
#include "usb_ulinker.h"
|
||||
#endif
|
||||
|
||||
#include "usb.h"
|
||||
#include "dwc_list.h"
|
||||
typedef unsigned int gfp_t;
|
||||
|
||||
//struct usb_ep;
|
||||
/**
|
||||
* struct usb_ep - device side representation of USB endpoint
|
||||
* @name:identifier for the endpoint, such as "ep-a" or "ep9in-bulk"
|
||||
* @ops: Function pointers used to access hardware-specific operations.
|
||||
* @ep_list:the gadget's ep_list holds all of its endpoints
|
||||
* @maxpacket:The maximum packet size used on this endpoint. The initial
|
||||
* value can sometimes be reduced (hardware allowing), according to
|
||||
* the endpoint descriptor used to configure the endpoint.
|
||||
* @driver_data:for use by the gadget driver. all other fields are
|
||||
* read-only to gadget drivers.
|
||||
*
|
||||
* the bus controller driver lists all the general purpose endpoints in
|
||||
* gadget->ep_list. the control endpoint (gadget->ep0) is not in that list,
|
||||
* and is accessed only in response to a driver setup() callback.
|
||||
*/
|
||||
struct usb_ep {
|
||||
void *driver_data;
|
||||
|
||||
const char *name;
|
||||
const struct usb_ep_ops *ops;
|
||||
//_LIST ep_list;//ModifiedByJD
|
||||
dwc_list_link_t ep_list;// by jimmy
|
||||
unsigned maxpacket:16;
|
||||
const struct usb_endpoint_descriptor *desc;
|
||||
};
|
||||
|
||||
struct usb_request;
|
||||
|
||||
typedef void (*usb_req_complete_t)(struct usb_ep *, struct usb_request *);
|
||||
|
||||
|
||||
/**
|
||||
* struct usb_request - describes one i/o request
|
||||
* @buf: Buffer used for data. Always provide this; some controllers
|
||||
* only use PIO, or don't use DMA for some endpoints.
|
||||
* @dma: DMA address corresponding to 'buf'. If you don't set this
|
||||
* field, and the usb controller needs one, it is responsible
|
||||
* for mapping and unmapping the buffer.
|
||||
* @length: Length of that data
|
||||
* @no_interrupt: If true, hints that no completion irq is needed.
|
||||
* Helpful sometimes with deep request queues that are handled
|
||||
* directly by DMA controllers.
|
||||
* @zero: If true, when writing data, makes the last packet be "short"
|
||||
* by adding a zero length packet as needed;
|
||||
* @short_not_ok: When reading data, makes short packets be
|
||||
* treated as errors (queue stops advancing till cleanup).
|
||||
* @complete: Function called when request completes, so this request and
|
||||
* its buffer may be re-used.
|
||||
* Reads terminate with a short packet, or when the buffer fills,
|
||||
* whichever comes first. When writes terminate, some data bytes
|
||||
* will usually still be in flight (often in a hardware fifo).
|
||||
* Errors (for reads or writes) stop the queue from advancing
|
||||
* until the completion function returns, so that any transfers
|
||||
* invalidated by the error may first be dequeued.
|
||||
* @context: For use by the completion callback
|
||||
* @list: For use by the gadget driver.
|
||||
* @status: Reports completion code, zero or a negative errno.
|
||||
* Normally, faults block the transfer queue from advancing until
|
||||
* the completion callback returns.
|
||||
* Code "-ESHUTDOWN" indicates completion caused by device disconnect,
|
||||
* or when the driver disabled the endpoint.
|
||||
* @actual: Reports bytes transferred to/from the buffer. For reads (OUT
|
||||
* transfers) this may be less than the requested length. If the
|
||||
* short_not_ok flag is set, short reads are treated as errors
|
||||
* even when status otherwise indicates successful completion.
|
||||
* Note that for writes (IN transfers) some data bytes may still
|
||||
* reside in a device-side FIFO when the request is reported as
|
||||
* complete.
|
||||
*
|
||||
* These are allocated/freed through the endpoint they're used with. The
|
||||
* hardware's driver can add extra per-request data to the memory it returns,
|
||||
* which often avoids separate memory allocations (potential failures),
|
||||
* later when the request is queued.
|
||||
*
|
||||
* Request flags affect request handling, such as whether a zero length
|
||||
* packet is written (the "zero" flag), whether a short read should be
|
||||
* treated as an error (blocking request queue advance, the "short_not_ok"
|
||||
* flag), or hinting that an interrupt is not required (the "no_interrupt"
|
||||
* flag, for use with deep request queues).
|
||||
*
|
||||
* Bulk endpoints can use any size buffers, and can also be used for interrupt
|
||||
* transfers. interrupt-only endpoints can be much less functional.
|
||||
*/
|
||||
// NOTE this is analagous to 'struct urb' on the host side,
|
||||
// except that it's thinner and promotes more pre-allocation.
|
||||
|
||||
struct usb_request {
|
||||
void *buf;
|
||||
unsigned length;
|
||||
dma_addr_t dma;
|
||||
|
||||
unsigned no_interrupt:1;
|
||||
unsigned zero:1;
|
||||
unsigned short_not_ok:1;
|
||||
|
||||
usb_req_complete_t complete;
|
||||
void *context;
|
||||
//_LIST list;//ModifiedByJD
|
||||
dwc_list_link_t list;// by jimmy
|
||||
int status;
|
||||
unsigned actual;
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* endpoint-specific parts of the api to the usb controller hardware.
|
||||
* unlike the urb model, (de)multiplexing layers are not required.
|
||||
* (so this api could slash overhead if used on the host side...)
|
||||
*
|
||||
* note that device side usb controllers commonly differ in how many
|
||||
* endpoints they support, as well as their capabilities.
|
||||
*/
|
||||
struct usb_ep_ops {
|
||||
int (*enable) (struct usb_ep *ep,
|
||||
const struct usb_endpoint_descriptor *desc);
|
||||
int (*disable) (struct usb_ep *ep);
|
||||
|
||||
struct usb_request *(*alloc_request) (struct usb_ep *ep,
|
||||
gfp_t gfp_flags);
|
||||
void (*free_request) (struct usb_ep *ep, struct usb_request *req);
|
||||
|
||||
void *(*alloc_buffer) (struct usb_ep *ep, unsigned bytes,
|
||||
dma_addr_t *dma, gfp_t gfp_flags);
|
||||
void (*free_buffer) (struct usb_ep *ep, void *buf, dma_addr_t dma,
|
||||
unsigned bytes);
|
||||
// NOTE: on 2.6, drivers may also use dma_map() and
|
||||
// dma_sync_single_*() to directly manage dma overhead.
|
||||
|
||||
int (*queue) (struct usb_ep *ep, struct usb_request *req,
|
||||
gfp_t gfp_flags);
|
||||
int (*dequeue) (struct usb_ep *ep, struct usb_request *req);
|
||||
|
||||
int (*set_halt) (struct usb_ep *ep, int value);
|
||||
int (*fifo_status) (struct usb_ep *ep);
|
||||
void (*fifo_flush) (struct usb_ep *ep);
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* usb_ep_enable - configure endpoint, making it usable
|
||||
* @ep:the endpoint being configured. may not be the endpoint named "ep0".
|
||||
* drivers discover endpoints through the ep_list of a usb_gadget.
|
||||
* @desc:descriptor for desired behavior. caller guarantees this pointer
|
||||
* remains valid until the endpoint is disabled; the data byte order
|
||||
* is little-endian (usb-standard).
|
||||
*
|
||||
* when configurations are set, or when interface settings change, the driver
|
||||
* will enable or disable the relevant endpoints. while it is enabled, an
|
||||
* endpoint may be used for i/o until the driver receives a disconnect() from
|
||||
* the host or until the endpoint is disabled.
|
||||
*
|
||||
* the ep0 implementation (which calls this routine) must ensure that the
|
||||
* hardware capabilities of each endpoint match the descriptor provided
|
||||
* for it. for example, an endpoint named "ep2in-bulk" would be usable
|
||||
* for interrupt transfers as well as bulk, but it likely couldn't be used
|
||||
* for iso transfers or for endpoint 14. some endpoints are fully
|
||||
* configurable, with more generic names like "ep-a". (remember that for
|
||||
* USB, "in" means "towards the USB master".)
|
||||
*
|
||||
* returns zero, or a negative error code.
|
||||
*/
|
||||
extern _LONG_CALL_
|
||||
int usb_ep_enable (struct usb_ep *ep, const struct usb_endpoint_descriptor *desc);
|
||||
|
||||
/**
|
||||
* usb_ep_disable - endpoint is no longer usable
|
||||
* @ep:the endpoint being unconfigured. may not be the endpoint named "ep0".
|
||||
*
|
||||
* no other task may be using this endpoint when this is called.
|
||||
* any pending and uncompleted requests will complete with status
|
||||
* indicating disconnect (-ESHUTDOWN) before this call returns.
|
||||
* gadget drivers must call usb_ep_enable() again before queueing
|
||||
* requests to the endpoint.
|
||||
*
|
||||
* returns zero, or a negative error code.
|
||||
*/
|
||||
extern _LONG_CALL_
|
||||
int usb_ep_disable (struct usb_ep *ep);
|
||||
|
||||
/**
|
||||
* usb_ep_alloc_request - allocate a request object to use with this endpoint
|
||||
* @ep:the endpoint to be used with with the request
|
||||
* @gfp_flags:GFP_* flags to use
|
||||
*
|
||||
* Request objects must be allocated with this call, since they normally
|
||||
* need controller-specific setup and may even need endpoint-specific
|
||||
* resources such as allocation of DMA descriptors.
|
||||
* Requests may be submitted with usb_ep_queue(), and receive a single
|
||||
* completion callback. Free requests with usb_ep_free_request(), when
|
||||
* they are no longer needed.
|
||||
*
|
||||
* Returns the request, or null if one could not be allocated.
|
||||
*/
|
||||
extern _LONG_CALL_ struct usb_request *
|
||||
usb_ep_alloc_request (struct usb_ep *ep, gfp_t gfp_flags);
|
||||
|
||||
/**
|
||||
* usb_ep_free_request - frees a request object
|
||||
* @ep:the endpoint associated with the request
|
||||
* @req:the request being freed
|
||||
*
|
||||
* Reverses the effect of usb_ep_alloc_request().
|
||||
* Caller guarantees the request is not queued, and that it will
|
||||
* no longer be requeued (or otherwise used).
|
||||
*/
|
||||
extern _LONG_CALL_ void
|
||||
usb_ep_free_request (struct usb_ep *ep, struct usb_request *req);
|
||||
#if 0
|
||||
/**
|
||||
* usb_ep_alloc_buffer - allocate an I/O buffer
|
||||
* @ep:the endpoint associated with the buffer
|
||||
* @len:length of the desired buffer
|
||||
* @dma:pointer to the buffer's DMA address; must be valid
|
||||
* @gfp_flags:GFP_* flags to use
|
||||
*
|
||||
* Returns a new buffer, or null if one could not be allocated.
|
||||
* The buffer is suitably aligned for dma, if that endpoint uses DMA,
|
||||
* and the caller won't have to care about dma-inconsistency
|
||||
* or any hidden "bounce buffer" mechanism. No additional per-request
|
||||
* DMA mapping will be required for such buffers.
|
||||
* Free it later with usb_ep_free_buffer().
|
||||
*
|
||||
* You don't need to use this call to allocate I/O buffers unless you
|
||||
* want to make sure drivers don't incur costs for such "bounce buffer"
|
||||
* copies or per-request DMA mappings.
|
||||
*/
|
||||
static inline void *
|
||||
usb_ep_alloc_buffer (struct usb_ep *ep, unsigned len, dma_addr_t *dma,
|
||||
gfp_t gfp_flags)
|
||||
{
|
||||
return ep->ops->alloc_buffer (ep, len, dma, gfp_flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_ep_free_buffer - frees an i/o buffer
|
||||
* @ep:the endpoint associated with the buffer
|
||||
* @buf:CPU view address of the buffer
|
||||
* @dma:the buffer's DMA address
|
||||
* @len:length of the buffer
|
||||
*
|
||||
* reverses the effect of usb_ep_alloc_buffer().
|
||||
* caller guarantees the buffer will no longer be accessed
|
||||
*/
|
||||
static inline void
|
||||
usb_ep_free_buffer (struct usb_ep *ep, void *buf, dma_addr_t dma, unsigned len)
|
||||
{
|
||||
ep->ops->free_buffer (ep, buf, dma, len);
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* usb_ep_queue - queues (submits) an I/O request to an endpoint.
|
||||
* @ep:the endpoint associated with the request
|
||||
* @req:the request being submitted
|
||||
* @gfp_flags: GFP_* flags to use in case the lower level driver couldn't
|
||||
* pre-allocate all necessary memory with the request.
|
||||
*
|
||||
* This tells the device controller to perform the specified request through
|
||||
* that endpoint (reading or writing a buffer). When the request completes,
|
||||
* including being canceled by usb_ep_dequeue(), the request's completion
|
||||
* routine is called to return the request to the driver. Any endpoint
|
||||
* (except control endpoints like ep0) may have more than one transfer
|
||||
* request queued; they complete in FIFO order. Once a gadget driver
|
||||
* submits a request, that request may not be examined or modified until it
|
||||
* is given back to that driver through the completion callback.
|
||||
*
|
||||
* Each request is turned into one or more packets. The controller driver
|
||||
* never merges adjacent requests into the same packet. OUT transfers
|
||||
* will sometimes use data that's already buffered in the hardware.
|
||||
* Drivers can rely on the fact that the first byte of the request's buffer
|
||||
* always corresponds to the first byte of some USB packet, for both
|
||||
* IN and OUT transfers.
|
||||
*
|
||||
* Bulk endpoints can queue any amount of data; the transfer is packetized
|
||||
* automatically. The last packet will be short if the request doesn't fill it
|
||||
* out completely. Zero length packets (ZLPs) should be avoided in portable
|
||||
* protocols since not all usb hardware can successfully handle zero length
|
||||
* packets. (ZLPs may be explicitly written, and may be implicitly written if
|
||||
* the request 'zero' flag is set.) Bulk endpoints may also be used
|
||||
* for interrupt transfers; but the reverse is not true, and some endpoints
|
||||
* won't support every interrupt transfer. (Such as 768 byte packets.)
|
||||
*
|
||||
* Interrupt-only endpoints are less functional than bulk endpoints, for
|
||||
* example by not supporting queueing or not handling buffers that are
|
||||
* larger than the endpoint's maxpacket size. They may also treat data
|
||||
* toggle differently.
|
||||
*
|
||||
* Control endpoints ... after getting a setup() callback, the driver queues
|
||||
* one response (even if it would be zero length). That enables the
|
||||
* status ack, after transfering data as specified in the response. Setup
|
||||
* functions may return negative error codes to generate protocol stalls.
|
||||
* (Note that some USB device controllers disallow protocol stall responses
|
||||
* in some cases.) When control responses are deferred (the response is
|
||||
* written after the setup callback returns), then usb_ep_set_halt() may be
|
||||
* used on ep0 to trigger protocol stalls.
|
||||
*
|
||||
* For periodic endpoints, like interrupt or isochronous ones, the usb host
|
||||
* arranges to poll once per interval, and the gadget driver usually will
|
||||
* have queued some data to transfer at that time.
|
||||
*
|
||||
* Returns zero, or a negative error code. Endpoints that are not enabled
|
||||
* report errors; errors will also be
|
||||
* reported when the usb peripheral is disconnected.
|
||||
*/
|
||||
extern _LONG_CALL_ int
|
||||
usb_ep_queue (struct usb_ep *ep, struct usb_request *req, gfp_t gfp_flags);
|
||||
|
||||
/**
|
||||
* usb_ep_dequeue - dequeues (cancels, unlinks) an I/O request from an endpoint
|
||||
* @ep:the endpoint associated with the request
|
||||
* @req:the request being canceled
|
||||
*
|
||||
* if the request is still active on the endpoint, it is dequeued and its
|
||||
* completion routine is called (with status -ECONNRESET); else a negative
|
||||
* error code is returned.
|
||||
*
|
||||
* note that some hardware can't clear out write fifos (to unlink the request
|
||||
* at the head of the queue) except as part of disconnecting from usb. such
|
||||
* restrictions prevent drivers from supporting configuration changes,
|
||||
* even to configuration zero (a "chapter 9" requirement).
|
||||
*/
|
||||
extern _LONG_CALL_ int usb_ep_dequeue (struct usb_ep *ep, struct usb_request *req);
|
||||
|
||||
/**
|
||||
* usb_ep_set_halt - sets the endpoint halt feature.
|
||||
* @ep: the non-isochronous endpoint being stalled
|
||||
*
|
||||
* Use this to stall an endpoint, perhaps as an error report.
|
||||
* Except for control endpoints,
|
||||
* the endpoint stays halted (will not stream any data) until the host
|
||||
* clears this feature; drivers may need to empty the endpoint's request
|
||||
* queue first, to make sure no inappropriate transfers happen.
|
||||
*
|
||||
* Note that while an endpoint CLEAR_FEATURE will be invisible to the
|
||||
* gadget driver, a SET_INTERFACE will not be. To reset endpoints for the
|
||||
* current altsetting, see usb_ep_clear_halt(). When switching altsettings,
|
||||
* it's simplest to use usb_ep_enable() or usb_ep_disable() for the endpoints.
|
||||
*
|
||||
* Returns zero, or a negative error code. On success, this call sets
|
||||
* underlying hardware state that blocks data transfers.
|
||||
* Attempts to halt IN endpoints will fail (returning -EAGAIN) if any
|
||||
* transfer requests are still queued, or if the controller hardware
|
||||
* (usually a FIFO) still holds bytes that the host hasn't collected.
|
||||
*/
|
||||
extern _LONG_CALL_ int usb_ep_set_halt (struct usb_ep *ep);
|
||||
|
||||
/**
|
||||
* usb_ep_clear_halt - clears endpoint halt, and resets toggle
|
||||
* @ep:the bulk or interrupt endpoint being reset
|
||||
*
|
||||
* Use this when responding to the standard usb "set interface" request,
|
||||
* for endpoints that aren't reconfigured, after clearing any other state
|
||||
* in the endpoint's i/o queue.
|
||||
*
|
||||
* Returns zero, or a negative error code. On success, this call clears
|
||||
* the underlying hardware state reflecting endpoint halt and data toggle.
|
||||
* Note that some hardware can't support this request (like pxa2xx_udc),
|
||||
* and accordingly can't correctly implement interface altsettings.
|
||||
*/
|
||||
extern _LONG_CALL_ int usb_ep_clear_halt (struct usb_ep *ep);
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* usb_ep_fifo_status - returns number of bytes in fifo, or error
|
||||
* @ep: the endpoint whose fifo status is being checked.
|
||||
*
|
||||
* FIFO endpoints may have "unclaimed data" in them in certain cases,
|
||||
* such as after aborted transfers. Hosts may not have collected all
|
||||
* the IN data written by the gadget driver (and reported by a request
|
||||
* completion). The gadget driver may not have collected all the data
|
||||
* written OUT to it by the host. Drivers that need precise handling for
|
||||
* fault reporting or recovery may need to use this call.
|
||||
*
|
||||
* This returns the number of such bytes in the fifo, or a negative
|
||||
* errno if the endpoint doesn't use a FIFO or doesn't support such
|
||||
* precise handling.
|
||||
*/
|
||||
static inline int
|
||||
usb_ep_fifo_status (struct usb_ep *ep)
|
||||
{
|
||||
if (ep->ops->fifo_status)
|
||||
return ep->ops->fifo_status (ep);
|
||||
else
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_ep_fifo_flush - flushes contents of a fifo
|
||||
* @ep: the endpoint whose fifo is being flushed.
|
||||
*
|
||||
* This call may be used to flush the "unclaimed data" that may exist in
|
||||
* an endpoint fifo after abnormal transaction terminations. The call
|
||||
* must never be used except when endpoint is not being used for any
|
||||
* protocol translation.
|
||||
*/
|
||||
static inline void
|
||||
usb_ep_fifo_flush (struct usb_ep *ep)
|
||||
{
|
||||
if (ep->ops->fifo_flush)
|
||||
ep->ops->fifo_flush (ep);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
/**
|
||||
* struct usb_gadget - represents a usb slave device
|
||||
* @ops: Function pointers used to access hardware-specific operations.
|
||||
* @ep0: Endpoint zero, used when reading or writing responses to
|
||||
* driver setup() requests
|
||||
* @ep_list: List of other endpoints supported by the device.
|
||||
* @speed: Speed of current connection to USB host.
|
||||
* @is_dualspeed: True if the controller supports both high and full speed
|
||||
* operation. If it does, the gadget driver must also support both.
|
||||
* @is_otg: True if the USB device port uses a Mini-AB jack, so that the
|
||||
* gadget driver must provide a USB OTG descriptor.
|
||||
* @is_a_peripheral: False unless is_otg, the "A" end of a USB cable
|
||||
* is in the Mini-AB jack, and HNP has been used to switch roles
|
||||
* so that the "A" device currently acts as A-Peripheral, not A-Host.
|
||||
* @a_hnp_support: OTG device feature flag, indicating that the A-Host
|
||||
* supports HNP at this port.
|
||||
* @a_alt_hnp_support: OTG device feature flag, indicating that the A-Host
|
||||
* only supports HNP on a different root port.
|
||||
* @b_hnp_enable: OTG device feature flag, indicating that the A-Host
|
||||
* enabled HNP support.
|
||||
* @name: Identifies the controller hardware type. Used in diagnostics
|
||||
* and sometimes configuration.
|
||||
* @dev: Driver model state for this abstract device.
|
||||
*
|
||||
* Gadgets have a mostly-portable "gadget driver" implementing device
|
||||
* functions, handling all usb configurations and interfaces. Gadget
|
||||
* drivers talk to hardware-specific code indirectly, through ops vectors.
|
||||
* That insulates the gadget driver from hardware details, and packages
|
||||
* the hardware endpoints through generic i/o queues. The "usb_gadget"
|
||||
* and "usb_ep" interfaces provide that insulation from the hardware.
|
||||
*
|
||||
* Except for the driver data, all fields in this structure are
|
||||
* read-only to the gadget driver. That driver data is part of the
|
||||
* "driver model" infrastructure in 2.6 (and later) kernels, and for
|
||||
* earlier systems is grouped in a similar structure that's not known
|
||||
* to the rest of the kernel.
|
||||
*
|
||||
* Values of the three OTG device feature flags are updated before the
|
||||
* setup() call corresponding to USB_REQ_SET_CONFIGURATION, and before
|
||||
* driver suspend() calls. They are valid only when is_otg, and when the
|
||||
* device is acting as a B-Peripheral (so is_a_peripheral is false).
|
||||
*/
|
||||
#include"rtl8195a_otg_zero.h"
|
||||
struct usb_gadget {
|
||||
/* readonly to gadget driver */
|
||||
const struct usb_gadget_ops *ops;
|
||||
struct usb_ep *ep0;
|
||||
// _LIST ep_list; /* of usb_ep */ //ModifiedByJD
|
||||
dwc_list_link_t ep_list; // by jimmy
|
||||
|
||||
enum usb_device_speed speed;
|
||||
enum usb_device_speed max_speed;
|
||||
enum usb_device_state state;
|
||||
unsigned is_dualspeed:1;
|
||||
unsigned is_otg:1;
|
||||
unsigned is_a_peripheral:1;
|
||||
unsigned b_hnp_enable:1;
|
||||
unsigned a_hnp_support:1;
|
||||
unsigned a_alt_hnp_support:1;
|
||||
const char *name;
|
||||
void *driver_data;
|
||||
void *device;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//struct usb_gadget;
|
||||
|
||||
/* the rest of the api to the controller hardware: device operations,
|
||||
* which don't involve endpoints (or i/o).
|
||||
*/
|
||||
struct usb_gadget_ops {
|
||||
int (*get_frame)(struct usb_gadget *);
|
||||
int (*wakeup)(struct usb_gadget *);
|
||||
int (*set_selfpowered) (struct usb_gadget *, int is_selfpowered);
|
||||
int (*vbus_session) (struct usb_gadget *, int is_active);
|
||||
int (*vbus_draw) (struct usb_gadget *, unsigned mA);
|
||||
int (*pullup) (struct usb_gadget *, int is_on);
|
||||
int (*ioctl)(struct usb_gadget *,
|
||||
unsigned code, unsigned long param);
|
||||
};
|
||||
|
||||
|
||||
#if 0 //wei add
|
||||
static inline void *
|
||||
dev_get_drvdata (struct device *dev)
|
||||
{
|
||||
return dev->driver_data;
|
||||
}
|
||||
|
||||
static inline void
|
||||
dev_set_drvdata (struct device *dev, void *data)
|
||||
{
|
||||
dev->driver_data = data;
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
static inline void set_gadget_data (struct usb_gadget *gadget, void *data)
|
||||
{ dev_set_drvdata (gadget->dev, data); }
|
||||
// { gadget->dev->driver_data = data; }
|
||||
static inline void *get_gadget_data (struct usb_gadget *gadget)
|
||||
{ return dev_get_drvdata (gadget->dev); }
|
||||
// { return gadget->dev->driver_data;}
|
||||
#endif
|
||||
|
||||
/* iterates the non-control endpoints; 'tmp' is a struct usb_ep pointer */
|
||||
#define gadget_for_each_ep(tmp,gadget) \
|
||||
list_for_each_entry(tmp, &(gadget)->ep_list, ep_list)
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* usb_gadget_frame_number - returns the current frame number
|
||||
* @gadget: controller that reports the frame number
|
||||
*
|
||||
* Returns the usb frame number, normally eleven bits from a SOF packet,
|
||||
* or negative errno if this device doesn't support this capability.
|
||||
*/
|
||||
static inline int usb_gadget_frame_number (struct usb_gadget *gadget)
|
||||
{
|
||||
return gadget->ops->get_frame(gadget);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_gadget_wakeup - tries to wake up the host connected to this gadget
|
||||
* @gadget: controller used to wake up the host
|
||||
*
|
||||
* Returns zero on success, else negative error code if the hardware
|
||||
* doesn't support such attempts, or its support has not been enabled
|
||||
* by the usb host. Drivers must return device descriptors that report
|
||||
* their ability to support this, or hosts won't enable it.
|
||||
*
|
||||
* This may also try to use SRP to wake the host and start enumeration,
|
||||
* even if OTG isn't otherwise in use. OTG devices may also start
|
||||
* remote wakeup even when hosts don't explicitly enable it.
|
||||
*/
|
||||
static inline int usb_gadget_wakeup (struct usb_gadget *gadget)
|
||||
{
|
||||
if (!gadget->ops->wakeup)
|
||||
return -EOPNOTSUPP;
|
||||
return gadget->ops->wakeup (gadget);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_gadget_set_selfpowered - sets the device selfpowered feature.
|
||||
* @gadget:the device being declared as self-powered
|
||||
*
|
||||
* this affects the device status reported by the hardware driver
|
||||
* to reflect that it now has a local power supply.
|
||||
*
|
||||
* returns zero on success, else negative errno.
|
||||
*/
|
||||
static inline int
|
||||
usb_gadget_set_selfpowered (struct usb_gadget *gadget)
|
||||
{
|
||||
xprintf("%s %s[%d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if (!gadget->ops->set_selfpowered)
|
||||
return -EOPNOTSUPP;
|
||||
return gadget->ops->set_selfpowered (gadget, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_gadget_clear_selfpowered - clear the device selfpowered feature.
|
||||
* @gadget:the device being declared as bus-powered
|
||||
*
|
||||
* this affects the device status reported by the hardware driver.
|
||||
* some hardware may not support bus-powered operation, in which
|
||||
* case this feature's value can never change.
|
||||
*
|
||||
* returns zero on success, else negative errno.
|
||||
*/
|
||||
static inline int
|
||||
usb_gadget_clear_selfpowered (struct usb_gadget *gadget)
|
||||
{
|
||||
if (!gadget->ops->set_selfpowered)
|
||||
return -EOPNOTSUPP;
|
||||
return gadget->ops->set_selfpowered (gadget, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_gadget_vbus_connect - Notify controller that VBUS is powered
|
||||
* @gadget:The device which now has VBUS power.
|
||||
*
|
||||
* This call is used by a driver for an external transceiver (or GPIO)
|
||||
* that detects a VBUS power session starting. Common responses include
|
||||
* resuming the controller, activating the D+ (or D-) pullup to let the
|
||||
* host detect that a USB device is attached, and starting to draw power
|
||||
* (8mA or possibly more, especially after SET_CONFIGURATION).
|
||||
*
|
||||
* Returns zero on success, else negative errno.
|
||||
*/
|
||||
static inline int
|
||||
usb_gadget_vbus_connect(struct usb_gadget *gadget)
|
||||
{
|
||||
if (!gadget->ops->vbus_session)
|
||||
return -EOPNOTSUPP;
|
||||
return gadget->ops->vbus_session (gadget, 1);
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* usb_gadget_vbus_draw - constrain controller's VBUS power usage
|
||||
* @gadget:The device whose VBUS usage is being described
|
||||
* @mA:How much current to draw, in milliAmperes. This should be twice
|
||||
* the value listed in the configuration descriptor bMaxPower field.
|
||||
*
|
||||
* This call is used by gadget drivers during SET_CONFIGURATION calls,
|
||||
* reporting how much power the device may consume. For example, this
|
||||
* could affect how quickly batteries are recharged.
|
||||
*
|
||||
* Returns zero on success, else negative errno.
|
||||
*/
|
||||
extern _LONG_CALL_ int
|
||||
usb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA);
|
||||
#if 0
|
||||
/**
|
||||
* usb_gadget_vbus_disconnect - notify controller about VBUS session end
|
||||
* @gadget:the device whose VBUS supply is being described
|
||||
*
|
||||
* This call is used by a driver for an external transceiver (or GPIO)
|
||||
* that detects a VBUS power session ending. Common responses include
|
||||
* reversing everything done in usb_gadget_vbus_connect().
|
||||
*
|
||||
* Returns zero on success, else negative errno.
|
||||
*/
|
||||
static inline int
|
||||
usb_gadget_vbus_disconnect(struct usb_gadget *gadget)
|
||||
{
|
||||
if (!gadget->ops->vbus_session)
|
||||
return -EOPNOTSUPP;
|
||||
return gadget->ops->vbus_session (gadget, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_gadget_connect - software-controlled connect to USB host
|
||||
* @gadget:the peripheral being connected
|
||||
*
|
||||
* Enables the D+ (or potentially D-) pullup. The host will start
|
||||
* enumerating this gadget when the pullup is active and a VBUS session
|
||||
* is active (the link is powered). This pullup is always enabled unless
|
||||
* usb_gadget_disconnect() has been used to disable it.
|
||||
*
|
||||
* Returns zero on success, else negative errno.
|
||||
*/
|
||||
static inline int
|
||||
usb_gadget_connect (struct usb_gadget *gadget)
|
||||
{
|
||||
if (!gadget->ops->pullup)
|
||||
return -EOPNOTSUPP;
|
||||
return gadget->ops->pullup (gadget, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_gadget_disconnect - software-controlled disconnect from USB host
|
||||
* @gadget:the peripheral being disconnected
|
||||
*
|
||||
* Disables the D+ (or potentially D-) pullup, which the host may see
|
||||
* as a disconnect (when a VBUS session is active). Not all systems
|
||||
* support software pullup controls.
|
||||
*
|
||||
* This routine may be used during the gadget driver bind() call to prevent
|
||||
* the peripheral from ever being visible to the USB host, unless later
|
||||
* usb_gadget_connect() is called. For example, user mode components may
|
||||
* need to be activated before the system can talk to hosts.
|
||||
*
|
||||
* Returns zero on success, else negative errno.
|
||||
*/
|
||||
static inline int
|
||||
usb_gadget_disconnect (struct usb_gadget *gadget)
|
||||
{
|
||||
if (!gadget->ops->pullup)
|
||||
return -EOPNOTSUPP;
|
||||
return gadget->ops->pullup (gadget, 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* struct usb_gadget_driver - driver for usb 'slave' devices
|
||||
* @function: String describing the gadget's function
|
||||
* @speed: Highest speed the driver handles.
|
||||
* @bind: Invoked when the driver is bound to a gadget, usually
|
||||
* after registering the driver.
|
||||
* At that point, ep0 is fully initialized, and ep_list holds
|
||||
* the currently-available endpoints.
|
||||
* Called in a context that permits sleeping.
|
||||
* @setup: Invoked for ep0 control requests that aren't handled by
|
||||
* the hardware level driver. Most calls must be handled by
|
||||
* the gadget driver, including descriptor and configuration
|
||||
* management. The 16 bit members of the setup data are in
|
||||
* USB byte order. Called in_interrupt; this may not sleep. Driver
|
||||
* queues a response to ep0, or returns negative to stall.
|
||||
* @disconnect: Invoked after all transfers have been stopped,
|
||||
* when the host is disconnected. May be called in_interrupt; this
|
||||
* may not sleep. Some devices can't detect disconnect, so this might
|
||||
* not be called except as part of controller shutdown.
|
||||
* @unbind: Invoked when the driver is unbound from a gadget,
|
||||
* usually from rmmod (after a disconnect is reported).
|
||||
* Called in a context that permits sleeping.
|
||||
* @suspend: Invoked on USB suspend. May be called in_interrupt.
|
||||
* @resume: Invoked on USB resume. May be called in_interrupt.
|
||||
* @driver: Driver model state for this driver.
|
||||
*
|
||||
* Devices are disabled till a gadget driver successfully bind()s, which
|
||||
* means the driver will handle setup() requests needed to enumerate (and
|
||||
* meet "chapter 9" requirements) then do some useful work.
|
||||
*
|
||||
* If gadget->is_otg is true, the gadget driver must provide an OTG
|
||||
* descriptor during enumeration, or else fail the bind() call. In such
|
||||
* cases, no USB traffic may flow until both bind() returns without
|
||||
* having called usb_gadget_disconnect(), and the USB host stack has
|
||||
* initialized.
|
||||
*
|
||||
* Drivers use hardware-specific knowledge to configure the usb hardware.
|
||||
* endpoint addressing is only one of several hardware characteristics that
|
||||
* are in descriptors the ep0 implementation returns from setup() calls.
|
||||
*
|
||||
* Except for ep0 implementation, most driver code shouldn't need change to
|
||||
* run on top of different usb controllers. It'll use endpoints set up by
|
||||
* that ep0 implementation.
|
||||
*
|
||||
* The usb controller driver handles a few standard usb requests. Those
|
||||
* include set_address, and feature flags for devices, interfaces, and
|
||||
* endpoints (the get_status, set_feature, and clear_feature requests).
|
||||
*
|
||||
* Accordingly, the driver's setup() callback must always implement all
|
||||
* get_descriptor requests, returning at least a device descriptor and
|
||||
* a configuration descriptor. Drivers must make sure the endpoint
|
||||
* descriptors match any hardware constraints. Some hardware also constrains
|
||||
* other descriptors. (The pxa250 allows only configurations 1, 2, or 3).
|
||||
*
|
||||
* The driver's setup() callback must also implement set_configuration,
|
||||
* and should also implement set_interface, get_configuration, and
|
||||
* get_interface. Setting a configuration (or interface) is where
|
||||
* endpoints should be activated or (config 0) shut down.
|
||||
*
|
||||
* (Note that only the default control endpoint is supported. Neither
|
||||
* hosts nor devices generally support control traffic except to ep0.)
|
||||
*
|
||||
* Most devices will ignore USB suspend/resume operations, and so will
|
||||
* not provide those callbacks. However, some may need to change modes
|
||||
* when the host is not longer directing those activities. For example,
|
||||
* local controls (buttons, dials, etc) may need to be re-enabled since
|
||||
* the (remote) host can't do that any longer; or an error state might
|
||||
* be cleared, to make the device behave identically whether or not
|
||||
* power is maintained.
|
||||
*/
|
||||
struct usb_gadget_driver {
|
||||
char *function;
|
||||
enum usb_device_speed max_speed;
|
||||
int (*bind)(struct usb_gadget *,
|
||||
struct usb_gadget_driver *);
|
||||
void (*unbind)(struct usb_gadget *);
|
||||
int (*setup)(struct usb_gadget *, const struct usb_ctrlrequest *);
|
||||
//CommentedByJD int (*setup)(dwc_otg_pcd_t *, const struct usb_ctrlrequest *);//ModifiedByJD
|
||||
void (*disconnect)(struct usb_gadget *);
|
||||
void (*suspend)(struct usb_gadget *);
|
||||
void (*resume)(struct usb_gadget *);
|
||||
|
||||
// FIXME support safe rmmod
|
||||
// struct device_driver *driver;
|
||||
void * driver;
|
||||
};
|
||||
|
||||
#include "dwc_otg_pcd_if.h"
|
||||
|
||||
struct gadget_wrapper {
|
||||
dwc_otg_pcd_t *pcd;
|
||||
|
||||
struct usb_gadget gadget;
|
||||
struct usb_gadget_driver *driver;
|
||||
|
||||
struct usb_ep ep0;
|
||||
struct usb_ep in_ep[16];
|
||||
struct usb_ep out_ep[16];
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* driver modules register and unregister, as usual.
|
||||
* these calls must be made in a context that can sleep.
|
||||
*
|
||||
* these will usually be implemented directly by the hardware-dependent
|
||||
* usb bus interface driver, which will only support a single driver.
|
||||
*/
|
||||
|
||||
/**
|
||||
* usb_gadget_register_driver - register a gadget driver
|
||||
* @driver:the driver being registered
|
||||
*
|
||||
* Call this in your gadget driver's module initialization function,
|
||||
* to tell the underlying usb controller driver about your driver.
|
||||
* The driver's bind() function will be called to bind it to a
|
||||
* gadget before this registration call returns. It's expected that
|
||||
* the bind() functions will be in init sections.
|
||||
* This function must be called in a context that can sleep.
|
||||
*/
|
||||
extern _LONG_CALL_ int usb_gadget_register_driver (struct usb_gadget_driver *driver);
|
||||
|
||||
/**
|
||||
* usb_gadget_unregister_driver - unregister a gadget driver
|
||||
* @driver:the driver being unregistered
|
||||
*
|
||||
* Call this in your gadget driver's module cleanup function,
|
||||
* to tell the underlying usb controller that your driver is
|
||||
* going away. If the controller is connected to a USB host,
|
||||
* it will first disconnect(). The driver is also requested
|
||||
* to unbind() and clean up any device state, before this procedure
|
||||
* finally returns. It's expected that the unbind() functions
|
||||
* will in in exit sections, so may not be linked in some kernels.
|
||||
* This function must be called in a context that can sleep.
|
||||
*/
|
||||
extern _LONG_CALL_ int usb_gadget_unregister_driver (struct usb_gadget_driver *driver);
|
||||
|
||||
/**
|
||||
* usb_free_descriptors - free descriptors returned by usb_copy_descriptors()
|
||||
* @v: vector of descriptors
|
||||
*/
|
||||
extern _LONG_CALL_ void usb_free_descriptors(struct usb_descriptor_header **v);
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* utility to simplify dealing with string descriptors */
|
||||
|
||||
/**
|
||||
* struct usb_string - wraps a C string and its USB id
|
||||
* @id:the (nonzero) ID for this string
|
||||
* @s:the string, in UTF-8 encoding
|
||||
*
|
||||
* If you're using usb_gadget_get_string(), use this to wrap a string
|
||||
* together with its ID.
|
||||
*/
|
||||
struct usb_string {
|
||||
u8 id;
|
||||
const char *s;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct usb_gadget_strings - a set of USB strings in a given language
|
||||
* @language:identifies the strings' language (0x0409 for en-us)
|
||||
* @strings:array of strings with their ids
|
||||
*
|
||||
* If you're using usb_gadget_get_string(), use this to wrap all the
|
||||
* strings for a given language.
|
||||
*/
|
||||
struct usb_gadget_strings {
|
||||
u16 language; /* 0x0409 for en-us */
|
||||
struct usb_string *strings;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* gadget_is_dualspeed - return true iff the hardware handles high speed
|
||||
* @g: controller that might support both high and full speeds
|
||||
*/
|
||||
extern _LONG_CALL_ int gadget_is_dualspeed(struct usb_gadget *g);
|
||||
#if 0
|
||||
/**
|
||||
* gadget_is_superspeed() - return true if the hardware handles superspeed
|
||||
* @g: controller that might support superspeed
|
||||
*/
|
||||
static inline int gadget_is_superspeed(struct usb_gadget *g)
|
||||
{
|
||||
return g->max_speed >= USB_SPEED_SUPER;
|
||||
}
|
||||
#endif
|
||||
/* put descriptor for string with that id into buf (buflen >= 256) */
|
||||
extern _LONG_CALL_ int usb_gadget_get_string (struct usb_gadget_strings *table, int id, u8 *buf);
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* utility to simplify managing config descriptors */
|
||||
|
||||
/* write vector of descriptors into buffer */
|
||||
extern _LONG_CALL_ int usb_descriptor_fillbuf(void *, unsigned,
|
||||
const struct usb_descriptor_header **);
|
||||
|
||||
/* build config descriptor from single descriptor vector */
|
||||
extern _LONG_CALL_ int usb_gadget_config_buf(const struct usb_config_descriptor *config,
|
||||
void *buf, unsigned buflen, const struct usb_descriptor_header **desc);
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
extern _LONG_CALL_ void set_gadget_data(struct usb_gadget *gadget, void *data);
|
||||
extern _LONG_CALL_ void *get_gadget_data(struct usb_gadget *gadget);
|
||||
|
||||
|
||||
/* utility wrapping a simple endpoint selection policy */
|
||||
#if 1
|
||||
extern _LONG_CALL_ struct usb_ep *usb_ep_autoconfig (struct usb_gadget *,
|
||||
struct usb_endpoint_descriptor *);// ULINKER_DEVINIT;
|
||||
|
||||
extern _LONG_CALL_ void usb_ep_autoconfig_reset (struct usb_gadget *);// ULINKER_DEVINIT;
|
||||
#endif
|
||||
//#endif /* __KERNEL__ */
|
||||
|
||||
#endif /* __LINUX_USB_GADGET_H */
|
||||
|
|
@ -0,0 +1,149 @@
|
|||
#ifndef _GENERIC_ERRNO_H
|
||||
#define _GENERIC_ERRNO_H
|
||||
|
||||
#define EPERM 1 /* Operation not permitted */
|
||||
#define ENOENT 2 /* No such file or directory */
|
||||
#define ESRCH 3 /* No such process */
|
||||
#define EINTR 4 /* Interrupted system call */
|
||||
#define EIO 5 /* I/O error */
|
||||
#define ENXIO 6 /* No such device or address */
|
||||
#define E2BIG 7 /* Argument list too long */
|
||||
#define ENOEXEC 8 /* Exec format error */
|
||||
#define EBADF 9 /* Bad file number */
|
||||
#define ECHILD 10 /* No child processes */
|
||||
#define EAGAIN 11 /* Try again */
|
||||
#define ENOMEM 12 /* Out of memory */
|
||||
#define EACCES 13 /* Permission denied */
|
||||
#define EFAULT 14 /* Bad address */
|
||||
#define ENOTBLK 15 /* Block device required */
|
||||
#define EBUSY 16 /* Device or resource busy */
|
||||
#define EEXIST 17 /* File exists */
|
||||
#define EXDEV 18 /* Cross-device link */
|
||||
#define ENODEV 19 /* No such device */
|
||||
#define ENOTDIR 20 /* Not a directory */
|
||||
#define EISDIR 21 /* Is a directory */
|
||||
#define EINVAL 22 /* Invalid argument */
|
||||
#define ENFILE 23 /* File table overflow */
|
||||
#define EMFILE 24 /* Too many open files */
|
||||
#define ENOTTY 25 /* Not a typewriter */
|
||||
#define ETXTBSY 26 /* Text file busy */
|
||||
#define EFBIG 27 /* File too large */
|
||||
#define ENOSPC 28 /* No space left on device */
|
||||
#define ESPIPE 29 /* Illegal seek */
|
||||
#define EROFS 30 /* Read-only file system */
|
||||
#define EMLINK 31 /* Too many links */
|
||||
#define EPIPE 32 /* Broken pipe */
|
||||
#define EDOM 33 /* Math argument out of domain of func */
|
||||
#define ERANGE 34 /* Math result not representable */
|
||||
|
||||
#define EDEADLK 35 /* Resource deadlock would occur */
|
||||
#define ENAMETOOLONG 36 /* File name too long */
|
||||
#define ENOLCK 37 /* No record locks available */
|
||||
#define ENOSYS 38 /* Function not implemented */
|
||||
#define ENOTEMPTY 39 /* Directory not empty */
|
||||
#define ELOOP 40 /* Too many symbolic links encountered */
|
||||
#define EWOULDBLOCK EAGAIN /* Operation would block */
|
||||
#define ENOMSG 42 /* No message of desired type */
|
||||
#define EIDRM 43 /* Identifier removed */
|
||||
#define ECHRNG 44 /* Channel number out of range */
|
||||
#define EL2NSYNC 45 /* Level 2 not synchronized */
|
||||
#define EL3HLT 46 /* Level 3 halted */
|
||||
#define EL3RST 47 /* Level 3 reset */
|
||||
#define ELNRNG 48 /* Link number out of range */
|
||||
#define EUNATCH 49 /* Protocol driver not attached */
|
||||
#define ENOCSI 50 /* No CSI structure available */
|
||||
#define EL2HLT 51 /* Level 2 halted */
|
||||
#define EBADE 52 /* Invalid exchange */
|
||||
#define EBADR 53 /* Invalid request descriptor */
|
||||
#define EXFULL 54 /* Exchange full */
|
||||
#define ENOANO 55 /* No anode */
|
||||
#define EBADRQC 56 /* Invalid request code */
|
||||
#define EBADSLT 57 /* Invalid slot */
|
||||
|
||||
#define EDEADLOCK EDEADLK
|
||||
|
||||
#define EBFONT 59 /* Bad font file format */
|
||||
#define ENOSTR 60 /* Device not a stream */
|
||||
#define ENODATA 61 /* No data available */
|
||||
#define ETIME 62 /* Timer expired */
|
||||
#define ENOSR 63 /* Out of streams resources */
|
||||
#define ENONET 64 /* Machine is not on the network */
|
||||
#define ENOPKG 65 /* Package not installed */
|
||||
#define EREMOTE 66 /* Object is remote */
|
||||
#define ENOLINK 67 /* Link has been severed */
|
||||
#define EADV 68 /* Advertise error */
|
||||
#define ESRMNT 69 /* Srmount error */
|
||||
#define ECOMM 70 /* Communication error on send */
|
||||
#define EPROTO 71 /* Protocol error */
|
||||
#define EMULTIHOP 72 /* Multihop attempted */
|
||||
#define EDOTDOT 73 /* RFS specific error */
|
||||
#define EBADMSG 74 /* Not a data message */
|
||||
#define EOVERFLOW 75 /* Value too large for defined data type */
|
||||
#define ENOTUNIQ 76 /* Name not unique on network */
|
||||
#define EBADFD 77 /* File descriptor in bad state */
|
||||
#define EREMCHG 78 /* Remote address changed */
|
||||
#define ELIBACC 79 /* Can not access a needed shared library */
|
||||
#define ELIBBAD 80 /* Accessing a corrupted shared library */
|
||||
#define ELIBSCN 81 /* .lib section in a.out corrupted */
|
||||
#define ELIBMAX 82 /* Attempting to link in too many shared libraries */
|
||||
#define ELIBEXEC 83 /* Cannot exec a shared library directly */
|
||||
#define EILSEQ 84 /* Illegal byte sequence */
|
||||
#define ERESTART 85 /* Interrupted system call should be restarted */
|
||||
#define ESTRPIPE 86 /* Streams pipe error */
|
||||
#define EUSERS 87 /* Too many users */
|
||||
#define ENOTSOCK 88 /* Socket operation on non-socket */
|
||||
#define EDESTADDRREQ 89 /* Destination address required */
|
||||
#define EMSGSIZE 90 /* Message too long */
|
||||
#define EPROTOTYPE 91 /* Protocol wrong type for socket */
|
||||
#define ENOPROTOOPT 92 /* Protocol not available */
|
||||
#define EPROTONOSUPPORT 93 /* Protocol not supported */
|
||||
#define ESOCKTNOSUPPORT 94 /* Socket type not supported */
|
||||
#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
|
||||
#define EPFNOSUPPORT 96 /* Protocol family not supported */
|
||||
#define EAFNOSUPPORT 97 /* Address family not supported by protocol */
|
||||
#define EADDRINUSE 98 /* Address already in use */
|
||||
#define EADDRNOTAVAIL 99 /* Cannot assign requested address */
|
||||
#define ENETDOWN 100 /* Network is down */
|
||||
#define ENETUNREACH 101 /* Network is unreachable */
|
||||
#define ENETRESET 102 /* Network dropped connection because of reset */
|
||||
#define ECONNABORTED 103 /* Software caused connection abort */
|
||||
#define ECONNRESET 104 /* Connection reset by peer */
|
||||
#define ENOBUFS 105 /* No buffer space available */
|
||||
#define EISCONN 106 /* Transport endpoint is already connected */
|
||||
#define ENOTCONN 107 /* Transport endpoint is not connected */
|
||||
#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */
|
||||
#define ETOOMANYREFS 109 /* Too many references: cannot splice */
|
||||
#define ETIMEDOUT 110 /* Connection timed out */
|
||||
#define ECONNREFUSED 111 /* Connection refused */
|
||||
#define EHOSTDOWN 112 /* Host is down */
|
||||
#define EHOSTUNREACH 113 /* No route to host */
|
||||
#define EALREADY 114 /* Operation already in progress */
|
||||
#define EINPROGRESS 115 /* Operation now in progress */
|
||||
#define ESTALE 116 /* Stale NFS file handle */
|
||||
#define EUCLEAN 117 /* Structure needs cleaning */
|
||||
#define ENOTNAM 118 /* Not a XENIX named type file */
|
||||
#define ENAVAIL 119 /* No XENIX semaphores available */
|
||||
#define EISNAM 120 /* Is a named type file */
|
||||
#define EREMOTEIO 121 /* Remote I/O error */
|
||||
#define EDQUOT 122 /* Quota exceeded */
|
||||
|
||||
#define ENOMEDIUM 123 /* No medium found */
|
||||
#define EMEDIUMTYPE 124 /* Wrong medium type */
|
||||
#define ECANCELED 125 /* Operation Canceled */
|
||||
#define ENOKEY 126 /* Required key not available */
|
||||
#define EKEYEXPIRED 127 /* Key has expired */
|
||||
#define EKEYREVOKED 128 /* Key has been revoked */
|
||||
#define EKEYREJECTED 129 /* Key was rejected by service */
|
||||
|
||||
/* for robust mutexes */
|
||||
#define EOWNERDEAD 130 /* Owner died */
|
||||
#define ENOTRECOVERABLE 131 /* State not recoverable */
|
||||
|
||||
#define ERFKILL 132 /* Operation not possible due to RF-kill */
|
||||
|
||||
#define EHWPOISON 133 /* Memory page has hardware error */
|
||||
|
||||
|
||||
#define ENOTSUPP 524 /* Operation is not supported */
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
#ifndef __LINUX_USB_ULINKER_H
|
||||
#define __LINUX_USB_ULINKER_H
|
||||
|
||||
//#include "linux/autoconf.h"
|
||||
|
||||
//#ifndef CONFIG_RTL_ULINKER_CUSTOMIZATION
|
||||
#if 1//ModifiedByJD
|
||||
#define ULINKER_ETHER_VID 0x0BDA
|
||||
#define ULINKER_ETHER_PID 0x8195
|
||||
#define ULINKER_MANUFACTURER "Realtek Semicoonductor Corp."
|
||||
|
||||
#define ULINKER_WINTOOLS_GUID "1CACC490-055C-4035-A026-1DAB0BDA8196"
|
||||
#define ULINKER_WINTOOLS_DISPLAY_NAME "Realtek RTL8196EU Universal Linker"
|
||||
#define ULINKER_WINTOOLS_CONTACT "nicfae@realtek.com.tw"
|
||||
#define ULINKER_WINTOOLS_DISPLAY_VERSION "v1.0.0.0"
|
||||
#define ULINKER_WINTOOLS_HELP_LINK "http://www.realtek.com.tw"
|
||||
#define ULINKER_WINTOOLS_PUBLISHER ULINKER_MANUFACTURER
|
||||
#define ULINKER_WINTOOLS_TARGET_DIR ULINKER_WINTOOLS_DISPLAY_NAME
|
||||
#else
|
||||
#define ULINKER_ETHER_VID CONFIG_RTL_ULINKER_VID
|
||||
#define ULINKER_ETHER_PID CONFIG_RTL_ULINKER_PID
|
||||
#define ULINKER_STORAGE_VID CONFIG_RTL_ULINKER_VID_S
|
||||
#define ULINKER_STORAGE_PID CONFIG_RTL_ULINKER_PID_S
|
||||
#define ULINKER_MANUFACTURER CONFIG_RTL_ULINKER_MANUFACTURE
|
||||
|
||||
#define ULINKER_WINTOOLS_GUID CONFIG_RTL_ULINKER_WINTOOLS_GUID
|
||||
#define ULINKER_WINTOOLS_DISPLAY_NAME CONFIG_RTL_ULINKER_WINTOOLS_DISPLAY_NAME
|
||||
#define ULINKER_WINTOOLS_CONTACT CONFIG_RTL_ULINKER_WINTOOLS_CONTACT
|
||||
#define ULINKER_WINTOOLS_DISPLAY_VERSION CONFIG_RTL_ULINKER_WINTOOLS_DISPLAY_VERSION
|
||||
#define ULINKER_WINTOOLS_HELP_LINK CONFIG_RTL_ULINKER_WINTOOLS_HELP_LINK
|
||||
#define ULINKER_WINTOOLS_PUBLISHER ULINKER_MANUFACTURER
|
||||
#define ULINKER_WINTOOLS_TARGET_DIR ULINKER_WINTOOLS_DISPLAY_NAME
|
||||
#endif
|
||||
|
||||
//------------------------------------------------
|
||||
// if you don't have a specific PID for storage, don't change following define of storage mode.
|
||||
//
|
||||
// begin: don't change
|
||||
#ifndef ULINKER_STORAGE_VID
|
||||
#define ULINKER_STORAGE_VID 0x0BDA
|
||||
#define ULINKER_STORAGE_PID 0x8197
|
||||
#endif
|
||||
|
||||
#define ULINKER_STORAGE_VID_STR "USB Ether "
|
||||
#define ULINKER_STORAGE_PID_DISK_STR "Driver DISC"
|
||||
#define ULINKER_STORAGE_PID_CDROM_STR "Driver CDROM"
|
||||
|
||||
#define ULINKER_WINTOOLS_DRIVER_PATH "Driver"
|
||||
// end: don't change
|
||||
//------------------------------------------------
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
#if defined(CONFIG_RTL_ULINKER)
|
||||
|
||||
#define ULINKER_DEVINIT
|
||||
#define ULINKER_DEVINITDATA
|
||||
#define ULINKER_DEVINITCONST
|
||||
#define ULINKER_DEVEXIT
|
||||
#define ULINKER_DEVEXITDATA
|
||||
#define ULINKER_DEVEXITCONST
|
||||
|
||||
#else
|
||||
|
||||
#define ULINKER_DEVINIT __devinit
|
||||
#define ULINKER_DEVINITDATA __devinitdata
|
||||
#define ULINKER_DEVINITCONST __devinitconst
|
||||
#define ULINKER_DEVEXIT __devexit
|
||||
#define ULINKER_DEVEXITDATA __devexitdata
|
||||
#define ULINKER_DEVEXITCONST __devexitconst
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* __LINUX_USB_ULINKER_H */
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#ifndef ROM_WLAN_RAM_MAP_H
|
||||
#define ROM_WLAN_RAM_MAP_H
|
||||
|
||||
struct _rom_wlan_ram_map {
|
||||
unsigned char * (*rtw_malloc)(unsigned int sz);
|
||||
void (*rtw_mfree)(unsigned char *pbuf, unsigned int sz);
|
||||
};
|
||||
|
||||
#endif /* ROM_WLAN_RAM_MAP_H */
|
||||
|
|
@ -0,0 +1,205 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
*/
|
||||
#ifndef _HAL_8195A_H_
|
||||
#define _HAL_8195A_H_
|
||||
|
||||
#include "platform_autoconf.h"
|
||||
#include "basic_types.h"
|
||||
#include "section_config.h"
|
||||
#include "rtl8195a_sys_on.h"
|
||||
#include "rtl8195a_peri_on.h"
|
||||
#include "hal_platform.h"
|
||||
#include "hal_pinmux.h"
|
||||
#include "hal_api.h"
|
||||
#include "hal_peri_on.h"
|
||||
#include "hal_misc.h"
|
||||
#include "hal_irqn.h"
|
||||
#include "hal_vector_table.h"
|
||||
#include "hal_diag.h"
|
||||
#include "hal_spi_flash.h"
|
||||
#include "rtl8195a_spi_flash.h"
|
||||
#include "hal_timer.h"
|
||||
#include "hal_util.h"
|
||||
#include "hal_efuse.h"
|
||||
#include "hal_soc_ps_monitor.h"
|
||||
#include "diag.h"
|
||||
#include "hal_common.h"
|
||||
#include "hal_soc_ps_monitor.h"
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- Cortex M3 Core Configuration
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/*!
|
||||
* @addtogroup Cortex_Core_Configuration Cortex M0 Core Configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define __CM3_REV 0x0200 /**< Core revision r0p0 */
|
||||
#define __MPU_PRESENT 1 /**< Defines if an MPU is present or not */
|
||||
#define __NVIC_PRIO_BITS 4 /**< Number of priority bits implemented in the NVIC */
|
||||
#define __Vendor_SysTickConfig 1 /**< Vendor specific implementation of SysTickConfig is defined */
|
||||
|
||||
#include "core_cm3.h"
|
||||
|
||||
#ifdef CONFIG_TIMER_EN
|
||||
#include "hal_timer.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_GDMA_EN
|
||||
#include "hal_gdma.h"
|
||||
#include "rtl8195a_gdma.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_GPIO_EN
|
||||
#include "hal_gpio.h"
|
||||
#include "rtl8195a_gpio.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SPI_COM_EN
|
||||
#include "hal_ssi.h"
|
||||
#include "rtl8195a_ssi.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_UART_EN
|
||||
#include "hal_uart.h"
|
||||
#include "rtl8195a_uart.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_I2C_EN
|
||||
#include "hal_i2c.h"
|
||||
#include "rtl8195a_i2c.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PCM_EN
|
||||
#include "hal_pcm.h"
|
||||
#include "rtl8195a_pcm.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PWM_EN
|
||||
#include "hal_pwm.h"
|
||||
#include "rtl8195a_pwm.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_I2S_EN
|
||||
#include "hal_i2s.h"
|
||||
#include "rtl8195a_i2s.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DAC_EN
|
||||
#include "hal_dac.h"
|
||||
#include "rtl8195a_dac.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ADC_EN
|
||||
#include "hal_adc.h"
|
||||
#include "rtl8195a_adc.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SDR_EN
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SPIC_EN
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SDIO_DEVICE_EN
|
||||
#include "hal_sdio.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NFC_EN
|
||||
#include "hal_nfc.h"
|
||||
#include "rtl8195a_nfc.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_WDG
|
||||
#include "rtl8195a_wdt.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USB_EN
|
||||
#include "hal_usb.h"
|
||||
#include "rtl8195a_usb.h"
|
||||
#endif
|
||||
|
||||
#include "hal_log_uart.h"
|
||||
|
||||
#ifdef CONFIG_MII_EN
|
||||
#include "hal_mii.h"
|
||||
#include "rtl8195a_mii.h"
|
||||
#endif
|
||||
|
||||
// firmware information, located at the header of Image2
|
||||
#define FW_VERSION (0x0100)
|
||||
#define FW_SUBVERSION (0x0001)
|
||||
#define FW_CHIP_ID (0x8195)
|
||||
#define FW_CHIP_VER (0x01)
|
||||
#define FW_BUS_TYPE (0x01) // the iNIC firmware type: USB/SDIO
|
||||
#define FW_INFO_RSV1 (0x00) // the firmware information reserved
|
||||
#define FW_INFO_RSV2 (0x00) // the firmware information reserved
|
||||
#define FW_INFO_RSV3 (0x00) // the firmware information reserved
|
||||
#define FW_INFO_RSV4 (0x00) // the firmware information reserved
|
||||
|
||||
#define FLASH_RESERVED_DATA_BASE 0x8000 // reserve 32K for Image1
|
||||
#define FLASH_SYSTEM_DATA_ADDR 0x9000 // reserve 32K+4K for Image1 + Reserved data
|
||||
// Flash Map for Calibration data
|
||||
#define FLASH_CAL_DATA_BASE 0xA000
|
||||
#define FLASH_CAL_DATA_ADDR(_offset) (FLASH_CAL_DATA_BASE + _offset)
|
||||
#define FLASH_CAL_DATA_SIZE 0x1000
|
||||
#define FLASH_SECTOR_SIZE 0x1000
|
||||
// SPIC Calibration Data
|
||||
#define FLASH_SPIC_PARA_OFFSET 0x80
|
||||
#define FLASH_SPIC_PARA_BASE (FLASH_SYSTEM_DATA_ADDR+FLASH_SPIC_PARA_OFFSET)
|
||||
// SDRC Calibration Data
|
||||
#define FLASH_SDRC_PARA_OFFSET 0x180
|
||||
#define FLASH_SDRC_PARA_BASE (FLASH_SYSTEM_DATA_ADDR+FLASH_SDRC_PARA_OFFSET)
|
||||
// ADC Calibration Data
|
||||
#define FLASH_ADC_PARA_OFFSET 0x200
|
||||
#define FLASH_ADC_PARA_BASE (FLASH_SYSTEM_DATA_ADDR+FLASH_ADC_PARA_OFFSET)
|
||||
|
||||
#define IMG_SIGN_RUN "81958711"
|
||||
#define IMG_SIGN_SWP "01958711"
|
||||
#define IMG_SIGN1_RUN 0x35393138 // "8195"
|
||||
#define IMG_SIGN1_SWP 0x35393130 // "0195"
|
||||
#define IMG_SIGN2_RUN 0x31313738 // "8711"
|
||||
#define IMG_SIGN2_SWP IMG_SIGN2_RUN // "8711"
|
||||
#define IMG2_SIGN_TXT "RTKWin"
|
||||
#define IMG2_SIGN_DW1_TXT 0x574b5452 // "RTKW"
|
||||
#define IMG2_SIGN_SW2_TXT 0x6e69 // "in"
|
||||
|
||||
typedef struct _RAM_FUNCTION_START_TABLE_ {
|
||||
void (*RamStartFun) (void); // Run for Init console, Run if ( v40000210 & 0x4000000 )
|
||||
void (*RamWakeupFun) (void); // Run if ( v40000210 & 0x20000000 )
|
||||
void (*RamPatchFun0) (void); // Run if ( v40000210 & 0x10000000 )
|
||||
void (*RamPatchFun1) (void); // Run if ( v400001F4 & 0x8000000 ) && ( v40000210 & 0x8000000 )
|
||||
void (*RamPatchFun2) (void); // Run for Init console, if ( v40000210 & 0x4000000 )
|
||||
}RAM_FUNCTION_START_TABLE, *PRAM_FUNCTION_START_TABLE;
|
||||
// START_RAM_FUN_SECTION RAM_FUNCTION_START_TABLE __ram_start_table_start__ =
|
||||
// {RamStartFun + 1, RamWakeupFun + 1, RamPatchFun0 + 1, RamPatchFun1 + 1, RamPatchFun2 + 1 };
|
||||
|
||||
#define IMG1_VALID_PATTEN_INIT() { 0x23, 0x79, 0x16, 0x88, 0xff, 0xff, 0xff, 0xff }
|
||||
// IMAGE1_VALID_PATTEN_SECTION uint8 RAM_IMG1_VALID_PATTEN[8] = IMG1_VALID_PATTEN_INIT();
|
||||
|
||||
typedef struct _RAM_START_FUNCTION_ {
|
||||
void (*RamStartFun) (void);
|
||||
}RAM_START_FUNCTION, *PRAM_START_FUNCTION;
|
||||
// IMAGE2_START_RAM_FUN_SECTION RAM_START_FUNCTION gImage2EntryFun0 = { InfraStart + 1 };
|
||||
|
||||
typedef struct __RAM_IMG2_VALID_PATTEN__ {
|
||||
char rtkwin[7];
|
||||
uint8_t x[13];
|
||||
} _RAM_IMG2_VALID_PATTEN, *_PRAM_IMG2_VALID_PATTEN;
|
||||
|
||||
// IMAGE2_VALID_PATTEN_SECTION _RAM_IMG2_VALID_PATTEN RAM_IMG2_VALID_PATTEN = RAM_IMG2_VALID_PATTEN_INIT();
|
||||
#define RAM_IMG2_VALID_PATTEN_INIT() { \
|
||||
{ IMG2_SIGN_TXT }, { 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)}}
|
||||
|
||||
|
||||
#endif //_HAL_8195A_H_
|
||||
|
|
@ -0,0 +1,389 @@
|
|||
/*
|
||||
* 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 "diag.h"
|
||||
#include "rtl8195a_adc.h"
|
||||
#include "hal_adc.h"
|
||||
|
||||
#ifdef CONFIG_ADC_EN
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
//Function Name:
|
||||
// HalI2CInit8195a
|
||||
//
|
||||
// Description:
|
||||
// To initialize I2C module by using the given data.
|
||||
//
|
||||
// Arguments:
|
||||
// [in] void *Data -
|
||||
// The I2C parameter data struct.
|
||||
//
|
||||
// Return:
|
||||
// The status of the DeInit process.
|
||||
// _EXIT_SUCCESS if the initialization succeeded.
|
||||
// _EXIT_FAILURE if the initialization failed.
|
||||
//
|
||||
// Note:
|
||||
// None
|
||||
//
|
||||
// See Also:
|
||||
// NA
|
||||
//
|
||||
// Author:
|
||||
// By Jason Deng, 2014-04-02.
|
||||
//
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
RTK_STATUS
|
||||
HalADCInit8195a(
|
||||
IN void *Data
|
||||
)
|
||||
{
|
||||
PHAL_ADC_INIT_DAT pHalAdcInitData = (PHAL_ADC_INIT_DAT)Data;
|
||||
uint32_t AdcTempDat;
|
||||
uint8_t AdcTempIdx = pHalAdcInitData->ADCIdx;
|
||||
|
||||
/* Enable ADC power cut */
|
||||
/*
|
||||
AdcTempDat = HAL_ADC_READ32(REG_ADC_POWER);
|
||||
AdcTempDat |= BIT_ADC_PWR_AUTO;
|
||||
HAL_ADC_WRITE32(REG_ADC_POWER, AdcTempDat);
|
||||
*/
|
||||
|
||||
/* ADC Control register set-up*/
|
||||
AdcTempDat = 0;
|
||||
AdcTempDat |= (BIT_CTRL_ADC_COMP_ONLY(pHalAdcInitData->ADCCompOnly) |
|
||||
BIT_CTRL_ADC_ONESHOT(pHalAdcInitData->ADCOneShotEn) |
|
||||
BIT_CTRL_ADC_OVERWRITE(pHalAdcInitData->ADCOverWREn) |
|
||||
BIT_CTRL_ADC_ENDIAN(pHalAdcInitData->ADCEndian) |
|
||||
BIT_CTRL_ADC_BURST_SIZE(pHalAdcInitData->ADCBurstSz) |
|
||||
BIT_CTRL_ADC_THRESHOLD(pHalAdcInitData->ADCOneShotTD) |
|
||||
BIT_CTRL_ADC_DBG_SEL(pHalAdcInitData->ADCDbgSel));
|
||||
HAL_ADC_WRITE32(REG_ADC_CONTROL,AdcTempDat);
|
||||
|
||||
DBG_8195A_ADC_LVL(HAL_ADC_LVL,"REG_ADC_CONTROL:%x\n", HAL_ADC_READ32(REG_ADC_CONTROL));
|
||||
|
||||
/* ADC compare value and compare method setting*/
|
||||
switch (AdcTempIdx) {
|
||||
case ADC0_SEL:
|
||||
AdcTempDat = HAL_ADC_READ32(REG_ADC_COMP_VALUE_L);
|
||||
AdcTempDat &= ~(BIT_ADC_COMP_TH_0(0xFFFF));
|
||||
AdcTempDat |= BIT_CTRL_ADC_COMP_TH_0(pHalAdcInitData->ADCCompTD);
|
||||
HAL_ADC_WRITE32(REG_ADC_COMP_VALUE_L, AdcTempDat);
|
||||
break;
|
||||
|
||||
case ADC1_SEL:
|
||||
AdcTempDat = HAL_ADC_READ32(REG_ADC_COMP_VALUE_L);
|
||||
AdcTempDat &= ~(BIT_ADC_COMP_TH_1(0xFFFF));
|
||||
AdcTempDat |= BIT_CTRL_ADC_COMP_TH_1(pHalAdcInitData->ADCCompTD);
|
||||
HAL_ADC_WRITE32(REG_ADC_COMP_VALUE_L, AdcTempDat);
|
||||
break;
|
||||
|
||||
case ADC2_SEL:
|
||||
AdcTempDat = HAL_ADC_READ32(REG_ADC_COMP_VALUE_H);
|
||||
AdcTempDat &= ~(BIT_ADC_COMP_TH_2(0xFFFF));
|
||||
AdcTempDat |= BIT_CTRL_ADC_COMP_TH_2(pHalAdcInitData->ADCCompTD);
|
||||
HAL_ADC_WRITE32(REG_ADC_COMP_VALUE_H, AdcTempDat);
|
||||
break;
|
||||
|
||||
case ADC3_SEL:
|
||||
AdcTempDat = HAL_ADC_READ32(REG_ADC_COMP_VALUE_H);
|
||||
AdcTempDat &= ~(BIT_ADC_COMP_TH_3(0xFFFF));
|
||||
AdcTempDat |= BIT_CTRL_ADC_COMP_TH_3(pHalAdcInitData->ADCCompTD);
|
||||
HAL_ADC_WRITE32(REG_ADC_COMP_VALUE_H, AdcTempDat);
|
||||
break;
|
||||
default:
|
||||
return _EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* ADC compare mode setting */
|
||||
AdcTempDat = HAL_ADC_READ32(REG_ADC_COMP_SET);
|
||||
AdcTempDat &= (~(0x01 << pHalAdcInitData->ADCIdx));
|
||||
AdcTempDat |= (BIT_CTRL_ADC_COMP_0_EN(pHalAdcInitData->ADCCompCtrl) <<
|
||||
pHalAdcInitData->ADCIdx);
|
||||
HAL_ADC_WRITE32(REG_ADC_COMP_SET, AdcTempDat);
|
||||
|
||||
/* ADC audio mode set-up */
|
||||
AdcTempDat = HAL_ADC_READ32(REG_ADC_ANAPAR_AD0);
|
||||
AdcTempDat &= ~(BIT_ADC_AUDIO_EN);
|
||||
AdcTempDat |= BIT_CTRL_ADC_AUDIO_EN(pHalAdcInitData->ADCAudioEn);
|
||||
HAL_ADC_WRITE32(REG_ADC_ANAPAR_AD0, AdcTempDat);
|
||||
|
||||
/* ADC enable manually setting */
|
||||
AdcTempDat = HAL_ADC_READ32(REG_ADC_ANAPAR_AD0);
|
||||
AdcTempDat &= ~(BIT_ADC_EN_MANUAL);
|
||||
AdcTempDat |= BIT_CTRL_ADC_EN_MANUAL(pHalAdcInitData->ADCEnManul);
|
||||
HAL_ADC_WRITE32(REG_ADC_ANAPAR_AD0, AdcTempDat);
|
||||
|
||||
|
||||
/* ADC analog parameter 0 */
|
||||
AdcTempDat = HAL_ADC_READ32(REG_ADC_ANAPAR_AD0);
|
||||
DBG_ADC_INFO("AD0:%x\n", AdcTempDat);
|
||||
//AdcTempDat |= (BIT0);
|
||||
if (pHalAdcInitData->ADCInInput == 1){
|
||||
AdcTempDat &= (~BIT14);
|
||||
}
|
||||
else {
|
||||
AdcTempDat |= (BIT14);
|
||||
}
|
||||
AdcTempDat &= (~(BIT3|BIT2));
|
||||
|
||||
/* Adjust VCM for C-Cut*/
|
||||
#ifdef CONFIG_CHIP_C_CUT
|
||||
AdcTempDat |= (BIT22);
|
||||
#endif
|
||||
|
||||
HAL_ADC_WRITE32(REG_ADC_ANAPAR_AD0, AdcTempDat);
|
||||
AdcTempDat = HAL_ADC_READ32(REG_ADC_ANAPAR_AD0);
|
||||
DBG_ADC_INFO("AD0:%x\n", AdcTempDat);
|
||||
|
||||
/* ADC analog parameter 1 */
|
||||
AdcTempDat = HAL_ADC_READ32(REG_ADC_ANAPAR_AD1);
|
||||
AdcTempDat &= (~BIT1);
|
||||
AdcTempDat |= (BIT2|BIT0);
|
||||
HAL_ADC_WRITE32(REG_ADC_ANAPAR_AD1, AdcTempDat);
|
||||
AdcTempDat = HAL_ADC_READ32(REG_ADC_ANAPAR_AD1);
|
||||
DBG_ADC_INFO("AD1:%x\n", AdcTempDat);
|
||||
|
||||
/* ADC analog parameter 2 */
|
||||
AdcTempDat = HAL_ADC_READ32(REG_ADC_ANAPAR_AD2);
|
||||
DBG_ADC_INFO("AD2:%x\n", AdcTempDat);
|
||||
AdcTempDat = 0x67884400;
|
||||
HAL_ADC_WRITE32(REG_ADC_ANAPAR_AD2, AdcTempDat);
|
||||
AdcTempDat = HAL_ADC_READ32(REG_ADC_ANAPAR_AD2);
|
||||
DBG_ADC_INFO("AD2:%x\n", AdcTempDat);
|
||||
|
||||
/* ADC analog parameter 3 */
|
||||
AdcTempDat = HAL_ADC_READ32(REG_ADC_ANAPAR_AD3);
|
||||
DBG_ADC_INFO("AD3:%x\n", AdcTempDat);
|
||||
AdcTempDat = 0x77780039;
|
||||
HAL_ADC_WRITE32(REG_ADC_ANAPAR_AD3, AdcTempDat);
|
||||
AdcTempDat = HAL_ADC_READ32(REG_ADC_ANAPAR_AD3);
|
||||
DBG_ADC_INFO("AD3:%x\n", AdcTempDat);
|
||||
|
||||
/* ADC analog parameter 4 */
|
||||
AdcTempDat = HAL_ADC_READ32(REG_ADC_ANAPAR_AD4);
|
||||
DBG_ADC_INFO("AD4:%x\n", AdcTempDat);
|
||||
AdcTempDat = 0x0004d501;
|
||||
HAL_ADC_WRITE32(REG_ADC_ANAPAR_AD4, AdcTempDat);
|
||||
AdcTempDat = HAL_ADC_READ32(REG_ADC_ANAPAR_AD4);
|
||||
DBG_ADC_INFO("AD4:%x\n", AdcTempDat);
|
||||
|
||||
/* ADC analog parameter 5 */
|
||||
AdcTempDat = HAL_ADC_READ32(REG_ADC_ANAPAR_AD5);
|
||||
DBG_ADC_INFO("AD5:%x\n", AdcTempDat);
|
||||
AdcTempDat = 0x1E010800;
|
||||
HAL_ADC_WRITE32(REG_ADC_ANAPAR_AD5, AdcTempDat);
|
||||
AdcTempDat = HAL_ADC_READ32(REG_ADC_ANAPAR_AD5);
|
||||
DBG_ADC_INFO("AD5:%x\n", AdcTempDat);
|
||||
|
||||
return _EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
//Function Name:
|
||||
// HalI2CInit8195a
|
||||
//
|
||||
// Description:
|
||||
// To initialize I2C module by using the given data.
|
||||
//
|
||||
// Arguments:
|
||||
// [in] void *Data -
|
||||
// The I2C parameter data struct.
|
||||
//
|
||||
// Return:
|
||||
// The status of the DeInit process.
|
||||
// _EXIT_SUCCESS if the initialization succeeded.
|
||||
// _EXIT_FAILURE if the initialization failed.
|
||||
//
|
||||
// Note:
|
||||
// None
|
||||
//
|
||||
// See Also:
|
||||
// NA
|
||||
//
|
||||
// Author:
|
||||
// By Jason Deng, 2014-04-02.
|
||||
//
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
RTK_STATUS
|
||||
HalADCDeInit8195a(
|
||||
IN void *Data
|
||||
)
|
||||
{
|
||||
uint32_t AdcTempDat;
|
||||
|
||||
AdcTempDat = HAL_ADC_READ32(REG_ADC_POWER);
|
||||
AdcTempDat &= ~(BIT_ADC_PWR_AUTO);
|
||||
HAL_ADC_WRITE32(REG_ADC_POWER, AdcTempDat);
|
||||
|
||||
return _EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
//Function Name:
|
||||
// HalI2CIntrCtrl8195a
|
||||
//
|
||||
// Description:
|
||||
// Modify the I2C interrupt mask according to the given value
|
||||
//
|
||||
// Arguments:
|
||||
// [in] void *Data -
|
||||
// The I2C parameter data struct.
|
||||
//
|
||||
// Return:
|
||||
// The status of the enable process.
|
||||
// _EXIT_SUCCESS if the de-initialization succeeded.
|
||||
// _EXIT_FAILURE if the de-initialization failed.
|
||||
//
|
||||
// Note:
|
||||
// None
|
||||
//
|
||||
// See Also:
|
||||
// NA
|
||||
//
|
||||
// Author:
|
||||
// By Jason Deng, 2014-02-18.
|
||||
//
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
RTK_STATUS
|
||||
HalADCEnableRtl8195a(
|
||||
IN void *Data
|
||||
){
|
||||
//PHAL_ADC_INIT_DAT pHalAdcInitData = (PHAL_ADC_INIT_DAT)Data;
|
||||
uint32_t AdcTempDat;
|
||||
DBG_ADC_INFO("HalADCEnableRtl8195a\n");
|
||||
|
||||
AdcTempDat = HAL_ADC_READ32(REG_ADC_POWER);
|
||||
|
||||
AdcTempDat &= (~BIT_ADC_PWR_AUTO);
|
||||
AdcTempDat |= 0x02;
|
||||
HAL_ADC_WRITE32(REG_ADC_POWER, AdcTempDat);
|
||||
AdcTempDat |= 0x04;
|
||||
HAL_ADC_WRITE32(REG_ADC_POWER, AdcTempDat);
|
||||
AdcTempDat &= (~0x08);
|
||||
HAL_ADC_WRITE32(REG_ADC_POWER, AdcTempDat);
|
||||
|
||||
AdcTempDat = (uint32_t)HAL_ADC_READ32(REG_ADC_POWER);
|
||||
DBG_ADC_INFO("HalADCEnableRtl8195a, power reg:%x\n",AdcTempDat);
|
||||
return _EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
//Function Name:
|
||||
// HalI2CIntrCtrl8195a
|
||||
//
|
||||
// Description:
|
||||
// Modify the I2C interrupt mask according to the given value
|
||||
//
|
||||
// Arguments:
|
||||
// [in] void *Data -
|
||||
// The I2C parameter data struct.
|
||||
//
|
||||
// Return:
|
||||
// The status of the enable process.
|
||||
// _EXIT_SUCCESS if the de-initialization succeeded.
|
||||
// _EXIT_FAILURE if the de-initialization failed.
|
||||
//
|
||||
// Note:
|
||||
// None
|
||||
//
|
||||
// See Also:
|
||||
// NA
|
||||
//
|
||||
// Author:
|
||||
// By Jason Deng, 2014-02-18.
|
||||
//
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
RTK_STATUS
|
||||
HalADCIntrCtrl8195a(
|
||||
IN void *Data
|
||||
){
|
||||
PHAL_ADC_INIT_DAT pHalAdcInitData = (PHAL_ADC_INIT_DAT)Data;
|
||||
|
||||
HAL_ADC_WRITE32(REG_ADC_INTR_EN, pHalAdcInitData->ADCIntrMSK);
|
||||
|
||||
return _EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
//Function Name:
|
||||
// HalI2CReceiveRtl8195a
|
||||
//
|
||||
// Description:
|
||||
// Directly read one data byte a I2C data fifo.
|
||||
//
|
||||
// Arguments:
|
||||
// [in] void *Data -
|
||||
// The I2C parameter data struct.
|
||||
//
|
||||
// Return:
|
||||
// The first data fifo content.
|
||||
//
|
||||
// Note:
|
||||
// None
|
||||
//
|
||||
// See Also:
|
||||
// NA
|
||||
//
|
||||
// Author:
|
||||
// By Jason Deng, 2014-02-18.
|
||||
//
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
uint32_t
|
||||
HalADCReceiveRtl8195a(
|
||||
IN void *Data
|
||||
){
|
||||
uint32_t AdcTempDat;
|
||||
|
||||
AdcTempDat = HAL_ADC_READ32(REG_ADC_FIFO_READ);
|
||||
|
||||
return (AdcTempDat);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
//Function Name:
|
||||
// HalI2CReadRegRtl8195a
|
||||
//
|
||||
// Description:
|
||||
// Directly read a I2C register according to the register offset.
|
||||
//
|
||||
// Arguments:
|
||||
// [in] void *Data -
|
||||
// The I2C parameter data struct.
|
||||
// [in] I2CReg -
|
||||
// The I2C register offset.
|
||||
//
|
||||
// Return:
|
||||
// The register content in uint32_t format.
|
||||
//
|
||||
// Note:
|
||||
// None
|
||||
//
|
||||
// See Also:
|
||||
// NA
|
||||
//
|
||||
// Author:
|
||||
// By Jason Deng, 2014-02-18.
|
||||
//
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
uint32_t
|
||||
HalADCReadRegRtl8195a(
|
||||
IN void *Data,
|
||||
IN uint8_t I2CReg
|
||||
){
|
||||
uint32_t AdcTempDat;
|
||||
|
||||
AdcTempDat = HAL_ADC_READ32(I2CReg);
|
||||
return (AdcTempDat);
|
||||
}
|
||||
|
||||
#endif // CONFIG_ADC_EN
|
||||
|
|
@ -0,0 +1,350 @@
|
|||
/*
|
||||
* 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_ADC_H_
|
||||
#define _RTL8195A_ADC_H_
|
||||
|
||||
|
||||
//================ Register Bit Field ==========================
|
||||
//2 REG_ADC_FIFO_READ
|
||||
|
||||
#define BIT_SHIFT_ADC_FIFO_RO 0
|
||||
#define BIT_MASK_ADC_FIFO_RO 0xffffffffL
|
||||
#define BIT_ADC_FIFO_RO(x) (((x) & BIT_MASK_ADC_FIFO_RO) << BIT_SHIFT_ADC_FIFO_RO)
|
||||
#define BIT_CTRL_ADC_FIFO_RO(x) (((x) & BIT_MASK_ADC_FIFO_RO) << BIT_SHIFT_ADC_FIFO_RO)
|
||||
#define BIT_GET_ADC_FIFO_RO(x) (((x) >> BIT_SHIFT_ADC_FIFO_RO) & BIT_MASK_ADC_FIFO_RO)
|
||||
|
||||
|
||||
//2 REG_ADC_CONTROL
|
||||
|
||||
#define BIT_SHIFT_ADC_DBG_SEL 24
|
||||
#define BIT_MASK_ADC_DBG_SEL 0x7
|
||||
#define BIT_ADC_DBG_SEL(x) (((x) & BIT_MASK_ADC_DBG_SEL) << BIT_SHIFT_ADC_DBG_SEL)
|
||||
#define BIT_CTRL_ADC_DBG_SEL(x) (((x) & BIT_MASK_ADC_DBG_SEL) << BIT_SHIFT_ADC_DBG_SEL)
|
||||
#define BIT_GET_ADC_DBG_SEL(x) (((x) >> BIT_SHIFT_ADC_DBG_SEL) & BIT_MASK_ADC_DBG_SEL)
|
||||
|
||||
|
||||
#define BIT_SHIFT_ADC_THRESHOLD 16
|
||||
#define BIT_MASK_ADC_THRESHOLD 0x3f
|
||||
#define BIT_ADC_THRESHOLD(x) (((x) & BIT_MASK_ADC_THRESHOLD) << BIT_SHIFT_ADC_THRESHOLD)
|
||||
#define BIT_CTRL_ADC_THRESHOLD(x) (((x) & BIT_MASK_ADC_THRESHOLD) << BIT_SHIFT_ADC_THRESHOLD)
|
||||
#define BIT_GET_ADC_THRESHOLD(x) (((x) >> BIT_SHIFT_ADC_THRESHOLD) & BIT_MASK_ADC_THRESHOLD)
|
||||
|
||||
|
||||
#define BIT_SHIFT_ADC_BURST_SIZE 8
|
||||
#define BIT_MASK_ADC_BURST_SIZE 0x1f
|
||||
#define BIT_ADC_BURST_SIZE(x) (((x) & BIT_MASK_ADC_BURST_SIZE) << BIT_SHIFT_ADC_BURST_SIZE)
|
||||
#define BIT_CTRL_ADC_BURST_SIZE(x) (((x) & BIT_MASK_ADC_BURST_SIZE) << BIT_SHIFT_ADC_BURST_SIZE)
|
||||
#define BIT_GET_ADC_BURST_SIZE(x) (((x) >> BIT_SHIFT_ADC_BURST_SIZE) & BIT_MASK_ADC_BURST_SIZE)
|
||||
|
||||
#define BIT_ADC_ENDIAN BIT(3)
|
||||
#define BIT_SHIFT_ADC_ENDIAN 3
|
||||
#define BIT_MASK_ADC_ENDIAN 0x1
|
||||
#define BIT_CTRL_ADC_ENDIAN(x) (((x) & BIT_MASK_ADC_ENDIAN) << BIT_SHIFT_ADC_ENDIAN)
|
||||
|
||||
#define BIT_ADC_OVERWRITE BIT(2)
|
||||
#define BIT_SHIFT_ADC_OVERWRITE 2
|
||||
#define BIT_MASK_ADC_OVERWRITE 0x1
|
||||
#define BIT_CTRL_ADC_OVERWRITE(x) (((x) & BIT_MASK_ADC_OVERWRITE) << BIT_SHIFT_ADC_OVERWRITE)
|
||||
|
||||
#define BIT_ADC_ONESHOT BIT(1)
|
||||
#define BIT_SHIFT_ADC_ONESHOT 1
|
||||
#define BIT_MASK_ADC_ONESHOT 0x1
|
||||
#define BIT_CTRL_ADC_ONESHOT(x) (((x) & BIT_MASK_ADC_ONESHOT) << BIT_SHIFT_ADC_ONESHOT)
|
||||
|
||||
#define BIT_ADC_COMP_ONLY BIT(0)
|
||||
#define BIT_SHIFT_ADC_COMP_ONLY 0
|
||||
#define BIT_MASK_ADC_COMP_ONLY 0x1
|
||||
#define BIT_CTRL_ADC_COMP_ONLY(x) (((x) & BIT_MASK_ADC_COMP_ONLY) << BIT_SHIFT_ADC_COMP_ONLY)
|
||||
|
||||
|
||||
//2 REG_ADC_INTR_EN
|
||||
#define BIT_ADC_AWAKE_CPU_EN BIT(7)
|
||||
#define BIT_SHIFT_ADC_AWAKE_CPU_EN 7
|
||||
#define BIT_MASK_ADC_AWAKE_CPU_EN 0x1
|
||||
#define BIT_CTRL_ADC_AWAKE_CPU_EN(x) (((x) & BIT_MASK_ADC_AWAKE_CPU_EN) << BIT_SHIFT_ADC_AWAKE_CPU_EN)
|
||||
|
||||
#define BIT_ADC_FIFO_RD_ERROR_EN BIT(6)
|
||||
#define BIT_SHIFT_ADC_FIFO_RD_ERROR_EN 6
|
||||
#define BIT_MASK_ADC_FIFO_RD_ERROR_EN 0x1
|
||||
#define BIT_CTRL_ADC_FIFO_RD_ERROR_EN(x) (((x) & BIT_MASK_ADC_FIFO_RD_ERROR_EN) << BIT_SHIFT_ADC_FIFO_RD_ERROR_EN)
|
||||
|
||||
#define BIT_ADC_FIFO_RD_REQ_EN BIT(5)
|
||||
#define BIT_SHIFT_ADC_FIFO_RD_REQ_EN 5
|
||||
#define BIT_MASK_ADC_FIFO_RD_REQ_EN 0x1
|
||||
#define BIT_CTRL_ADC_FIFO_RD_REQ_EN(x) (((x) & BIT_MASK_ADC_FIFO_RD_REQ_EN) << BIT_SHIFT_ADC_FIFO_RD_REQ_EN)
|
||||
|
||||
#define BIT_ADC_FIFO_FULL_EN BIT(4)
|
||||
#define BIT_SHIFT_ADC_FIFO_FULL_EN 4
|
||||
#define BIT_MASK_ADC_FIFO_FULL_EN 0x1
|
||||
#define BIT_CTRL_ADC_FIFO_FULL_EN(x) (((x) & BIT_MASK_ADC_FIFO_FULL_EN) << BIT_SHIFT_ADC_FIFO_FULL_EN)
|
||||
|
||||
#define BIT_ADC_COMP_3_EN BIT(3)
|
||||
#define BIT_SHIFT_ADC_COMP_3_EN 3
|
||||
#define BIT_MASK_ADC_COMP_3_EN 0x1
|
||||
#define BIT_CTRL_ADC_COMP_3_EN(x) (((x) & BIT_MASK_ADC_COMP_3_EN) << BIT_SHIFT_ADC_COMP_3_EN)
|
||||
|
||||
#define BIT_ADC_COMP_2_EN BIT(2)
|
||||
#define BIT_SHIFT_ADC_COMP_2_EN 2
|
||||
#define BIT_MASK_ADC_COMP_2_EN 0x1
|
||||
#define BIT_CTRL_ADC_COMP_2_EN(x) (((x) & BIT_MASK_ADC_COMP_2_EN) << BIT_SHIFT_ADC_COMP_2_EN)
|
||||
|
||||
#define BIT_ADC_COMP_1_EN BIT(1)
|
||||
#define BIT_SHIFT_ADC_COMP_1_EN 1
|
||||
#define BIT_MASK_ADC_COMP_1_EN 0x1
|
||||
#define BIT_CTRL_ADC_COMP_1_EN(x) (((x) & BIT_MASK_ADC_COMP_1_EN) << BIT_SHIFT_ADC_COMP_1_EN)
|
||||
|
||||
#define BIT_ADC_COMP_0_EN BIT(0)
|
||||
#define BIT_SHIFT_ADC_COMP_0_EN 0
|
||||
#define BIT_MASK_ADC_COMP_0_EN 0x1
|
||||
#define BIT_CTRL_ADC_COMP_0_EN(x) (((x) & BIT_MASK_ADC_COMP_0_EN) << BIT_SHIFT_ADC_COMP_0_EN)
|
||||
|
||||
|
||||
//2 REG_ADC_INTR_STS
|
||||
#define BIT_ADC_FIFO_THRESHOLD BIT(7)
|
||||
#define BIT_SHIFT_ADC_FIFO_THRESHOLD 7
|
||||
#define BIT_MASK_ADC_FIFO_THRESHOLD 0x1
|
||||
#define BIT_CTRL_ADC_FIFO_THRESHOLD(x) (((x) & BIT_MASK_ADC_FIFO_THRESHOLD) << BIT_SHIFT_ADC_FIFO_THRESHOLD)
|
||||
|
||||
#define BIT_ADC_FIFO_RD_ERROR_ST BIT(6)
|
||||
#define BIT_SHIFT_ADC_FIFO_RD_ERROR_ST 6
|
||||
#define BIT_MASK_ADC_FIFO_RD_ERROR_ST 0x1
|
||||
#define BIT_CTRL_ADC_FIFO_RD_ERROR_ST(x) (((x) & BIT_MASK_ADC_FIFO_RD_ERROR_ST) << BIT_SHIFT_ADC_FIFO_RD_ERROR_ST)
|
||||
|
||||
#define BIT_ADC_FIFO_RD_REQ_ST BIT(5)
|
||||
#define BIT_SHIFT_ADC_FIFO_RD_REQ_ST 5
|
||||
#define BIT_MASK_ADC_FIFO_RD_REQ_ST 0x1
|
||||
#define BIT_CTRL_ADC_FIFO_RD_REQ_ST(x) (((x) & BIT_MASK_ADC_FIFO_RD_REQ_ST) << BIT_SHIFT_ADC_FIFO_RD_REQ_ST)
|
||||
|
||||
#define BIT_ADC_FIFO_FULL_ST BIT(4)
|
||||
#define BIT_SHIFT_ADC_FIFO_FULL_ST 4
|
||||
#define BIT_MASK_ADC_FIFO_FULL_ST 0x1
|
||||
#define BIT_CTRL_ADC_FIFO_FULL_ST(x) (((x) & BIT_MASK_ADC_FIFO_FULL_ST) << BIT_SHIFT_ADC_FIFO_FULL_ST)
|
||||
|
||||
#define BIT_ADC_COMP_3_ST BIT(3)
|
||||
#define BIT_SHIFT_ADC_COMP_3_ST 3
|
||||
#define BIT_MASK_ADC_COMP_3_ST 0x1
|
||||
#define BIT_CTRL_ADC_COMP_3_ST(x) (((x) & BIT_MASK_ADC_COMP_3_ST) << BIT_SHIFT_ADC_COMP_3_ST)
|
||||
|
||||
#define BIT_ADC_COMP_2_ST BIT(2)
|
||||
#define BIT_SHIFT_ADC_COMP_2_ST 2
|
||||
#define BIT_MASK_ADC_COMP_2_ST 0x1
|
||||
#define BIT_CTRL_ADC_COMP_2_ST(x) (((x) & BIT_MASK_ADC_COMP_2_ST) << BIT_SHIFT_ADC_COMP_2_ST)
|
||||
|
||||
#define BIT_ADC_COMP_1_ST BIT(1)
|
||||
#define BIT_SHIFT_ADC_COMP_1_ST 1
|
||||
#define BIT_MASK_ADC_COMP_1_ST 0x1
|
||||
#define BIT_CTRL_ADC_COMP_1_ST(x) (((x) & BIT_MASK_ADC_COMP_1_ST) << BIT_SHIFT_ADC_COMP_1_ST)
|
||||
|
||||
#define BIT_ADC_COMP_0_ST BIT(0)
|
||||
#define BIT_SHIFT_ADC_COMP_0_ST 0
|
||||
#define BIT_MASK_ADC_COMP_0_ST 0x1
|
||||
#define BIT_CTRL_ADC_COMP_0_ST(x) (((x) & BIT_MASK_ADC_COMP_0_ST) << BIT_SHIFT_ADC_COMP_0_ST)
|
||||
|
||||
|
||||
//2 REG_ADC_COMP_VALUE_L
|
||||
|
||||
#define BIT_SHIFT_ADC_COMP_TH_1 16
|
||||
#define BIT_MASK_ADC_COMP_TH_1 0xffff
|
||||
#define BIT_ADC_COMP_TH_1(x) (((x) & BIT_MASK_ADC_COMP_TH_1) << BIT_SHIFT_ADC_COMP_TH_1)
|
||||
#define BIT_CTRL_ADC_COMP_TH_1(x) (((x) & BIT_MASK_ADC_COMP_TH_1) << BIT_SHIFT_ADC_COMP_TH_1)
|
||||
#define BIT_GET_ADC_COMP_TH_1(x) (((x) >> BIT_SHIFT_ADC_COMP_TH_1) & BIT_MASK_ADC_COMP_TH_1)
|
||||
|
||||
|
||||
#define BIT_SHIFT_ADC_COMP_TH_0 0
|
||||
#define BIT_MASK_ADC_COMP_TH_0 0xffff
|
||||
#define BIT_ADC_COMP_TH_0(x) (((x) & BIT_MASK_ADC_COMP_TH_0) << BIT_SHIFT_ADC_COMP_TH_0)
|
||||
#define BIT_CTRL_ADC_COMP_TH_0(x) (((x) & BIT_MASK_ADC_COMP_TH_0) << BIT_SHIFT_ADC_COMP_TH_0)
|
||||
#define BIT_GET_ADC_COMP_TH_0(x) (((x) >> BIT_SHIFT_ADC_COMP_TH_0) & BIT_MASK_ADC_COMP_TH_0)
|
||||
|
||||
|
||||
//2 REG_ADC_COMP_VALUE_H
|
||||
|
||||
#define BIT_SHIFT_ADC_COMP_TH_3 16
|
||||
#define BIT_MASK_ADC_COMP_TH_3 0xffff
|
||||
#define BIT_ADC_COMP_TH_3(x) (((x) & BIT_MASK_ADC_COMP_TH_3) << BIT_SHIFT_ADC_COMP_TH_3)
|
||||
#define BIT_CTRL_ADC_COMP_TH_3(x) (((x) & BIT_MASK_ADC_COMP_TH_3) << BIT_SHIFT_ADC_COMP_TH_3)
|
||||
#define BIT_GET_ADC_COMP_TH_3(x) (((x) >> BIT_SHIFT_ADC_COMP_TH_3) & BIT_MASK_ADC_COMP_TH_3)
|
||||
|
||||
|
||||
#define BIT_SHIFT_ADC_COMP_TH_2 0
|
||||
#define BIT_MASK_ADC_COMP_TH_2 0xffff
|
||||
#define BIT_ADC_COMP_TH_2(x) (((x) & BIT_MASK_ADC_COMP_TH_2) << BIT_SHIFT_ADC_COMP_TH_2)
|
||||
#define BIT_CTRL_ADC_COMP_TH_2(x) (((x) & BIT_MASK_ADC_COMP_TH_2) << BIT_SHIFT_ADC_COMP_TH_2)
|
||||
#define BIT_GET_ADC_COMP_TH_2(x) (((x) >> BIT_SHIFT_ADC_COMP_TH_2) & BIT_MASK_ADC_COMP_TH_2)
|
||||
|
||||
|
||||
//2 REG_ADC_COMP_SET
|
||||
|
||||
#define BIT_SHIFT_ADC_GREATER_THAN 0
|
||||
#define BIT_MASK_ADC_GREATER_THAN 0xf
|
||||
#define BIT_ADC_GREATER_THAN(x) (((x) & BIT_MASK_ADC_GREATER_THAN) << BIT_SHIFT_ADC_GREATER_THAN)
|
||||
#define BIT_CTRL_ADC_GREATER_THAN(x) (((x) & BIT_MASK_ADC_GREATER_THAN) << BIT_SHIFT_ADC_GREATER_THAN)
|
||||
#define BIT_GET_ADC_GREATER_THAN(x) (((x) >> BIT_SHIFT_ADC_GREATER_THAN) & BIT_MASK_ADC_GREATER_THAN)
|
||||
|
||||
|
||||
//2 REG_ADC_POWER
|
||||
|
||||
#define BIT_SHIFT_ADC_PWR_CUT_CNTR 16
|
||||
#define BIT_MASK_ADC_PWR_CUT_CNTR 0xff
|
||||
#define BIT_ADC_PWR_CUT_CNTR(x) (((x) & BIT_MASK_ADC_PWR_CUT_CNTR) << BIT_SHIFT_ADC_PWR_CUT_CNTR)
|
||||
#define BIT_CTRL_ADC_PWR_CUT_CNTR(x) (((x) & BIT_MASK_ADC_PWR_CUT_CNTR) << BIT_SHIFT_ADC_PWR_CUT_CNTR)
|
||||
#define BIT_GET_ADC_PWR_CUT_CNTR(x) (((x) >> BIT_SHIFT_ADC_PWR_CUT_CNTR) & BIT_MASK_ADC_PWR_CUT_CNTR)
|
||||
|
||||
#define BIT_ADC_FIFO_ON_ST BIT(11)
|
||||
#define BIT_SHIFT_ADC_FIFO_ON_ST 11
|
||||
#define BIT_MASK_ADC_FIFO_ON_ST 0x1
|
||||
#define BIT_CTRL_ADC_FIFO_ON_ST(x) (((x) & BIT_MASK_ADC_FIFO_ON_ST) << BIT_SHIFT_ADC_FIFO_ON_ST)
|
||||
|
||||
#define BIT_ADC_ISO_ON_ST BIT(10)
|
||||
#define BIT_SHIFT_ADC_ISO_ON_ST 10
|
||||
#define BIT_MASK_ADC_ISO_ON_ST 0x1
|
||||
#define BIT_CTRL_ADC_ISO_ON_ST(x) (((x) & BIT_MASK_ADC_ISO_ON_ST) << BIT_SHIFT_ADC_ISO_ON_ST)
|
||||
|
||||
#define BIT_ADC_PWR33_ON_ST BIT(9)
|
||||
#define BIT_SHIFT_ADC_PWR33_ON_ST 9
|
||||
#define BIT_MASK_ADC_PWR33_ON_ST 0x1
|
||||
#define BIT_CTRL_ADC_PWR33_ON_ST(x) (((x) & BIT_MASK_ADC_PWR33_ON_ST) << BIT_SHIFT_ADC_PWR33_ON_ST)
|
||||
|
||||
#define BIT_ADC_PWR12_ON_ST BIT(8)
|
||||
#define BIT_SHIFT_ADC_PWR12_ON_ST 8
|
||||
#define BIT_MASK_ADC_PWR12_ON_ST 0x1
|
||||
#define BIT_CTRL_ADC_PWR12_ON_ST(x) (((x) & BIT_MASK_ADC_PWR12_ON_ST) << BIT_SHIFT_ADC_PWR12_ON_ST)
|
||||
|
||||
#define BIT_ADC_ISO_MANUAL BIT(3)
|
||||
#define BIT_SHIFT_ADC_ISO_MANUAL 3
|
||||
#define BIT_MASK_ADC_ISO_MANUAL 0x1
|
||||
#define BIT_CTRL_ADC_ISO_MANUAL(x) (((x) & BIT_MASK_ADC_ISO_MANUAL) << BIT_SHIFT_ADC_ISO_MANUAL)
|
||||
|
||||
#define BIT_ADC_PWR33_MANUAL BIT(2)
|
||||
#define BIT_SHIFT_ADC_PWR33_MANUAL 2
|
||||
#define BIT_MASK_ADC_PWR33_MANUAL 0x1
|
||||
#define BIT_CTRL_ADC_PWR33_MANUAL(x) (((x) & BIT_MASK_ADC_PWR33_MANUAL) << BIT_SHIFT_ADC_PWR33_MANUAL)
|
||||
|
||||
#define BIT_ADC_PWR12_MANUAL BIT(1)
|
||||
#define BIT_SHIFT_ADC_PWR12_MANUAL 1
|
||||
#define BIT_MASK_ADC_PWR12_MANUAL 0x1
|
||||
#define BIT_CTRL_ADC_PWR12_MANUAL(x) (((x) & BIT_MASK_ADC_PWR12_MANUAL) << BIT_SHIFT_ADC_PWR12_MANUAL)
|
||||
|
||||
#define BIT_ADC_PWR_AUTO BIT(0)
|
||||
#define BIT_SHIFT_ADC_PWR_AUTO 0
|
||||
#define BIT_MASK_ADC_PWR_AUTO 0x1
|
||||
#define BIT_CTRL_ADC_PWR_AUTO(x) (((x) & BIT_MASK_ADC_PWR_AUTO) << BIT_SHIFT_ADC_PWR_AUTO)
|
||||
|
||||
|
||||
//2 REG_ADC_ANAPAR_AD0
|
||||
|
||||
#define BIT_SHIFT_ADC_ANAPAR_AD0 2
|
||||
#define BIT_MASK_ADC_ANAPAR_AD0 0x3fffffff
|
||||
#define BIT_ADC_ANAPAR_AD0(x) (((x) & BIT_MASK_ADC_ANAPAR_AD0) << BIT_SHIFT_ADC_ANAPAR_AD0)
|
||||
#define BIT_CTRL_ADC_ANAPAR_AD0(x) (((x) & BIT_MASK_ADC_ANAPAR_AD0) << BIT_SHIFT_ADC_ANAPAR_AD0)
|
||||
#define BIT_GET_ADC_ANAPAR_AD0(x) (((x) >> BIT_SHIFT_ADC_ANAPAR_AD0) & BIT_MASK_ADC_ANAPAR_AD0)
|
||||
|
||||
#define BIT_ADC_AUDIO_EN BIT(1)
|
||||
#define BIT_SHIFT_ADC_AUDIO_EN 1
|
||||
#define BIT_MASK_ADC_AUDIO_EN 0x1
|
||||
#define BIT_CTRL_ADC_AUDIO_EN(x) (((x) & BIT_MASK_ADC_AUDIO_EN) << BIT_SHIFT_ADC_AUDIO_EN)
|
||||
|
||||
#define BIT_ADC_EN_MANUAL BIT(0)
|
||||
#define BIT_SHIFT_ADC_EN_MANUAL 0
|
||||
#define BIT_MASK_ADC_EN_MANUAL 0x1
|
||||
#define BIT_CTRL_ADC_EN_MANUAL(x) (((x) & BIT_MASK_ADC_EN_MANUAL) << BIT_SHIFT_ADC_EN_MANUAL)
|
||||
|
||||
|
||||
//2 REG_ADC_ANAPAR_AD1
|
||||
|
||||
#define BIT_SHIFT_ADC_ANAPAR_AD1 0
|
||||
#define BIT_MASK_ADC_ANAPAR_AD1 0xffffffffL
|
||||
#define BIT_ADC_ANAPAR_AD1(x) (((x) & BIT_MASK_ADC_ANAPAR_AD1) << BIT_SHIFT_ADC_ANAPAR_AD1)
|
||||
#define BIT_CTRL_ADC_ANAPAR_AD1(x) (((x) & BIT_MASK_ADC_ANAPAR_AD1) << BIT_SHIFT_ADC_ANAPAR_AD1)
|
||||
#define BIT_GET_ADC_ANAPAR_AD1(x) (((x) >> BIT_SHIFT_ADC_ANAPAR_AD1) & BIT_MASK_ADC_ANAPAR_AD1)
|
||||
|
||||
|
||||
//2 REG_ADC_ANAPAR_AD2
|
||||
|
||||
#define BIT_SHIFT_ADC_ANAPAR_AD2 0
|
||||
#define BIT_MASK_ADC_ANAPAR_AD2 0xffffffffL
|
||||
#define BIT_ADC_ANAPAR_AD2(x) (((x) & BIT_MASK_ADC_ANAPAR_AD2) << BIT_SHIFT_ADC_ANAPAR_AD2)
|
||||
#define BIT_CTRL_ADC_ANAPAR_AD2(x) (((x) & BIT_MASK_ADC_ANAPAR_AD2) << BIT_SHIFT_ADC_ANAPAR_AD2)
|
||||
#define BIT_GET_ADC_ANAPAR_AD2(x) (((x) >> BIT_SHIFT_ADC_ANAPAR_AD2) & BIT_MASK_ADC_ANAPAR_AD2)
|
||||
|
||||
|
||||
//2 REG_ADC_ANAPAR_AD3
|
||||
|
||||
#define BIT_SHIFT_ADC_ANAPAR_AD3 0
|
||||
#define BIT_MASK_ADC_ANAPAR_AD3 0xffffffffL
|
||||
#define BIT_ADC_ANAPAR_AD3(x) (((x) & BIT_MASK_ADC_ANAPAR_AD3) << BIT_SHIFT_ADC_ANAPAR_AD3)
|
||||
#define BIT_CTRL_ADC_ANAPAR_AD3(x) (((x) & BIT_MASK_ADC_ANAPAR_AD3) << BIT_SHIFT_ADC_ANAPAR_AD3)
|
||||
#define BIT_GET_ADC_ANAPAR_AD3(x) (((x) >> BIT_SHIFT_ADC_ANAPAR_AD3) & BIT_MASK_ADC_ANAPAR_AD3)
|
||||
|
||||
|
||||
//2 REG_ADC_ANAPAR_AD4
|
||||
|
||||
#define BIT_SHIFT_ADC_ANAPAR_AD4 0
|
||||
#define BIT_MASK_ADC_ANAPAR_AD4 0xffffffffL
|
||||
#define BIT_ADC_ANAPAR_AD4(x) (((x) & BIT_MASK_ADC_ANAPAR_AD4) << BIT_SHIFT_ADC_ANAPAR_AD4)
|
||||
#define BIT_CTRL_ADC_ANAPAR_AD4(x) (((x) & BIT_MASK_ADC_ANAPAR_AD4) << BIT_SHIFT_ADC_ANAPAR_AD4)
|
||||
#define BIT_GET_ADC_ANAPAR_AD4(x) (((x) >> BIT_SHIFT_ADC_ANAPAR_AD4) & BIT_MASK_ADC_ANAPAR_AD4)
|
||||
|
||||
|
||||
//2 REG_ADC_ANAPAR_AD5
|
||||
|
||||
#define BIT_SHIFT_ADC_ANAPAR_AD5 0
|
||||
#define BIT_MASK_ADC_ANAPAR_AD5 0xffffffffL
|
||||
#define BIT_ADC_ANAPAR_AD5(x) (((x) & BIT_MASK_ADC_ANAPAR_AD5) << BIT_SHIFT_ADC_ANAPAR_AD5)
|
||||
#define BIT_CTRL_ADC_ANAPAR_AD5(x) (((x) & BIT_MASK_ADC_ANAPAR_AD5) << BIT_SHIFT_ADC_ANAPAR_AD5)
|
||||
#define BIT_GET_ADC_ANAPAR_AD5(x) (((x) >> BIT_SHIFT_ADC_ANAPAR_AD5) & BIT_MASK_ADC_ANAPAR_AD5)
|
||||
|
||||
|
||||
//2 REG_ADC_CALI_DATA
|
||||
|
||||
#define BIT_SHIFT_ADC_CALI_DATA_6 16
|
||||
#define BIT_MASK_ADC_CALI_DATA_6 0xffff
|
||||
#define BIT_ADC_CALI_DATA_6(x) (((x) & BIT_MASK_ADC_CALI_DATA_6) << BIT_SHIFT_ADC_CALI_DATA_6)
|
||||
#define BIT_CTRL_ADC_CALI_DATA_6(x) (((x) & BIT_MASK_ADC_CALI_DATA_6) << BIT_SHIFT_ADC_CALI_DATA_6)
|
||||
#define BIT_GET_ADC_CALI_DATA_6(x) (((x) >> BIT_SHIFT_ADC_CALI_DATA_6) & BIT_MASK_ADC_CALI_DATA_6)
|
||||
|
||||
|
||||
#define BIT_SHIFT_ADC_CALI_DATA_0 0
|
||||
#define BIT_MASK_ADC_CALI_DATA_0 0xffff
|
||||
#define BIT_ADC_CALI_DATA_0(x) (((x) & BIT_MASK_ADC_CALI_DATA_0) << BIT_SHIFT_ADC_CALI_DATA_0)
|
||||
#define BIT_CTRL_ADC_CALI_DATA_0(x) (((x) & BIT_MASK_ADC_CALI_DATA_0) << BIT_SHIFT_ADC_CALI_DATA_0)
|
||||
#define BIT_GET_ADC_CALI_DATA_0(x) (((x) >> BIT_SHIFT_ADC_CALI_DATA_0) & BIT_MASK_ADC_CALI_DATA_0)
|
||||
|
||||
//================ Register Reg Field =========================
|
||||
#define REG_ADC_FIFO_READ 0x0000
|
||||
#define REG_ADC_CONTROL 0x0004
|
||||
#define REG_ADC_INTR_EN 0x0008
|
||||
#define REG_ADC_INTR_STS 0x000C
|
||||
#define REG_ADC_COMP_VALUE_L 0x0010
|
||||
#define REG_ADC_COMP_VALUE_H 0x0014
|
||||
#define REG_ADC_COMP_SET 0x0018
|
||||
#define REG_ADC_POWER 0x001C
|
||||
#define REG_ADC_ANAPAR_AD0 0x0020
|
||||
#define REG_ADC_ANAPAR_AD1 0x0024
|
||||
#define REG_ADC_ANAPAR_AD2 0x0028
|
||||
#define REG_ADC_ANAPAR_AD3 0x002C
|
||||
#define REG_ADC_ANAPAR_AD4 0x0030
|
||||
#define REG_ADC_ANAPAR_AD5 0x0034
|
||||
#define REG_ADC_CALI_DATA 0x0038
|
||||
|
||||
//================ ADC HAL related enumeration ==================
|
||||
|
||||
//================ ADC Function Prototypes =====================
|
||||
#define HAL_ADC_WRITE32(addr, value) HAL_WRITE32(ADC_REG_BASE,addr,value)
|
||||
#define HAL_ADC_READ32(addr) HAL_READ32(ADC_REG_BASE,addr)
|
||||
|
||||
RTK_STATUS HalADCInit8195a(IN void *Data);
|
||||
RTK_STATUS HalADCDeInit8195a(IN void *Data);
|
||||
RTK_STATUS HalADCEnableRtl8195a(IN void *Data);
|
||||
RTK_STATUS HalADCIntrCtrl8195a(IN void *Data);
|
||||
uint32_t HalADCReceiveRtl8195a(IN void *Data);
|
||||
uint32_t HalADCReadRegRtl8195a(IN void *Data,IN uint8_t I2CReg);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,269 @@
|
|||
/*
|
||||
* 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 "rtl8195a_dac.h"
|
||||
#include "hal_dac.h"
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
//Function Name:
|
||||
// HalDACInit8195a
|
||||
//
|
||||
// Description:
|
||||
// To initialize DAC module by using the given data.
|
||||
//
|
||||
// Arguments:
|
||||
// [in] void *Data -
|
||||
// The DAC parameter data struct.
|
||||
//
|
||||
// Return:
|
||||
// The status of the DeInit process.
|
||||
// _EXIT_SUCCESS if the initialization succeeded.
|
||||
// _EXIT_FAILURE if the initialization failed.
|
||||
//
|
||||
// Note:
|
||||
// None
|
||||
//
|
||||
// See Also:
|
||||
// NA
|
||||
//
|
||||
// Author:
|
||||
// By Jason Deng, 2014-04-15.
|
||||
//
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
RTK_STATUS
|
||||
HalDACInit8195a(
|
||||
IN void *Data
|
||||
){
|
||||
PHAL_DAC_INIT_DAT pHalDacInitData = (PHAL_DAC_INIT_DAT)Data;
|
||||
uint32_t DacTempDat;
|
||||
uint8_t DacTempIdx = pHalDacInitData->DACIdx;
|
||||
|
||||
/* Enable DAC power cut */
|
||||
DacTempDat = HAL_DAC_READ32(0, REG_DAC_PWR_CTRL);
|
||||
DacTempDat |= BIT_DAC_PWR_AUTO;
|
||||
|
||||
HAL_DAC_WRITE32(0, REG_DAC_PWR_CTRL, DacTempDat);
|
||||
|
||||
/* Disable DAC module first */
|
||||
HAL_DAC_WRITE32(DacTempIdx, REG_DAC_CTRL, 0);
|
||||
|
||||
/* Setup DAC module */
|
||||
DacTempDat = 0;
|
||||
DacTempDat |= (BIT_CTRL_DAC_SPEED(pHalDacInitData->DACDataRate) |
|
||||
BIT_CTRL_DAC_ENDIAN(pHalDacInitData->DACEndian) |
|
||||
BIT_CTRL_DAC_FILTER_SETTLE(pHalDacInitData->DACFilterSet) |
|
||||
BIT_CTRL_DAC_BURST_SIZE(pHalDacInitData->DACBurstSz) |
|
||||
BIT_CTRL_DAC_DBG_SEL(pHalDacInitData->DACDbgSel) |
|
||||
BIT_CTRL_DAC_DSC_DBG_SEL(pHalDacInitData->DACDscDbgSel) |
|
||||
BIT_CTRL_DAC_BYPASS_DSC(pHalDacInitData->DACBPDsc) |
|
||||
BIT_CTRL_DAC_DELTA_SIGMA(pHalDacInitData->DACDeltaSig));
|
||||
|
||||
HAL_DAC_WRITE32(DacTempIdx, REG_DAC_CTRL, DacTempDat);
|
||||
|
||||
return _EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
//Function Name:
|
||||
// HalI2CInit8195a
|
||||
//
|
||||
// Description:
|
||||
// To initialize I2C module by using the given data.
|
||||
//
|
||||
// Arguments:
|
||||
// [in] void *Data -
|
||||
// The I2C parameter data struct.
|
||||
//
|
||||
// Return:
|
||||
// The status of the DeInit process.
|
||||
// _EXIT_SUCCESS if the initialization succeeded.
|
||||
// _EXIT_FAILURE if the initialization failed.
|
||||
//
|
||||
// Note:
|
||||
// None
|
||||
//
|
||||
// See Also:
|
||||
// NA
|
||||
//
|
||||
// Author:
|
||||
// By Jason Deng, 2014-04-02.
|
||||
//
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
RTK_STATUS
|
||||
HalDACDeInit8195a(
|
||||
IN void *Data
|
||||
){
|
||||
PHAL_DAC_INIT_DAT pHalDacInitData = (PHAL_DAC_INIT_DAT)Data;
|
||||
uint32_t DacTempDat;
|
||||
|
||||
DacTempDat = HAL_DAC_READ32(pHalDacInitData->DACIdx, REG_DAC_CTRL);
|
||||
DacTempDat &= (~BIT_DAC_FIFO_EN);
|
||||
HAL_DAC_WRITE32(pHalDacInitData->DACIdx, REG_DAC_CTRL ,DacTempDat);
|
||||
|
||||
return _EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
//Function Name:
|
||||
// HalI2CIntrCtrl8195a
|
||||
//
|
||||
// Description:
|
||||
// Modify the I2C interrupt mask according to the given value
|
||||
//
|
||||
// Arguments:
|
||||
// [in] void *Data -
|
||||
// The I2C parameter data struct.
|
||||
//
|
||||
// Return:
|
||||
// The status of the enable process.
|
||||
// _EXIT_SUCCESS if the de-initialization succeeded.
|
||||
// _EXIT_FAILURE if the de-initialization failed.
|
||||
//
|
||||
// Note:
|
||||
// None
|
||||
//
|
||||
// See Also:
|
||||
// NA
|
||||
//
|
||||
// Author:
|
||||
// By Jason Deng, 2014-02-18.
|
||||
//
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
RTK_STATUS
|
||||
HalDACEnableRtl8195a(
|
||||
IN void *Data
|
||||
){
|
||||
PHAL_DAC_INIT_DAT pHalDacInitData = (PHAL_DAC_INIT_DAT)Data;
|
||||
uint32_t DacTempDat;
|
||||
uint8_t DacTempIdx = pHalDacInitData->DACIdx;
|
||||
|
||||
DacTempDat = HAL_DAC_READ32(DacTempIdx, REG_DAC_CTRL);
|
||||
DacTempDat &= (~BIT_DAC_FIFO_EN);
|
||||
|
||||
DacTempDat |= BIT_CTRL_DAC_FIFO_EN(pHalDacInitData->DACEn);
|
||||
HAL_DAC_WRITE32(DacTempIdx, REG_DAC_CTRL, DacTempDat);
|
||||
|
||||
return _EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
//Function Name:
|
||||
// HalI2CIntrCtrl8195a
|
||||
//
|
||||
// Description:
|
||||
// Modify the I2C interrupt mask according to the given value
|
||||
//
|
||||
// Arguments:
|
||||
// [in] void *Data -
|
||||
// The I2C parameter data struct.
|
||||
//
|
||||
// Return:
|
||||
// The status of the enable process.
|
||||
// _EXIT_SUCCESS if the de-initialization succeeded.
|
||||
// _EXIT_FAILURE if the de-initialization failed.
|
||||
//
|
||||
// Note:
|
||||
// None
|
||||
//
|
||||
// See Also:
|
||||
// NA
|
||||
//
|
||||
// Author:
|
||||
// By Jason Deng, 2014-02-18.
|
||||
//
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
RTK_STATUS
|
||||
HalDACIntrCtrl8195a(
|
||||
IN void *Data
|
||||
){
|
||||
PHAL_DAC_INIT_DAT pHalDacInitData = (PHAL_DAC_INIT_DAT)Data;
|
||||
|
||||
HAL_DAC_WRITE32(pHalDacInitData->DACIdx, REG_DAC_INTR_CTRL, pHalDacInitData->DACIntrMSK);
|
||||
|
||||
return _EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
//Function Name:
|
||||
// HalI2CReceiveRtl8195a
|
||||
//
|
||||
// Description:
|
||||
// Directly read one data byte a I2C data fifo.
|
||||
//
|
||||
// Arguments:
|
||||
// [in] void *Data -
|
||||
// The I2C parameter data struct.
|
||||
//
|
||||
// Return:
|
||||
// The first data fifo content.
|
||||
//
|
||||
// Note:
|
||||
// None
|
||||
//
|
||||
// See Also:
|
||||
// NA
|
||||
//
|
||||
// Author:
|
||||
// By Jason Deng, 2014-02-18.
|
||||
//
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
uint8_t
|
||||
HalDACSendRtl8195a(
|
||||
IN void *Data
|
||||
){
|
||||
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
//Function Name:
|
||||
// HalDACReadRegRtl8195a
|
||||
//
|
||||
// Description:
|
||||
//
|
||||
//
|
||||
// Arguments:
|
||||
// [in] void *Data -
|
||||
// The DAC parameter data struct.
|
||||
// [in] I2CReg -
|
||||
// The DAC register offset.
|
||||
//
|
||||
// Return:
|
||||
// The DAC register content in uint32_t format.
|
||||
//
|
||||
// Note:
|
||||
// None
|
||||
//
|
||||
// See Also:
|
||||
// NA
|
||||
//
|
||||
// Author:
|
||||
// By Jason Deng, 2014-04-15.
|
||||
//
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
uint32_t
|
||||
HalDACReadRegRtl8195a(
|
||||
IN void *Data,
|
||||
IN uint8_t I2CReg
|
||||
){
|
||||
PHAL_DAC_INIT_DAT pHalDacInitData = (PHAL_DAC_INIT_DAT)Data;
|
||||
|
||||
//DBG_8195A_DAC("dac read reg idx:%x\n",pHalDacInitData->DACIdx);
|
||||
//DBG_8195A_DAC("dac read reg offset:%x\n",I2CReg);
|
||||
|
||||
return (uint32_t)HAL_DAC_READ32(pHalDacInitData->DACIdx, I2CReg);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,294 @@
|
|||
#ifndef _RTL8195A_DAC_H_
|
||||
#define _RTL8195A_DAC_H_
|
||||
|
||||
//================ Register Bit Field ==========================
|
||||
//2 REG_DAC0_FIFO_WR
|
||||
|
||||
#define BIT_SHIFT_DAC0_FIFO_WO 0
|
||||
#define BIT_MASK_DAC0_FIFO_WO 0xffffffffL
|
||||
#define BIT_DAC0_FIFO_WO(x) (((x) & BIT_MASK_DAC0_FIFO_WO) << BIT_SHIFT_DAC0_FIFO_WO)
|
||||
#define BIT_CTRL_DAC0_FIFO_WO(x) (((x) & BIT_MASK_DAC0_FIFO_WO) << BIT_SHIFT_DAC0_FIFO_WO)
|
||||
#define BIT_GET_DAC0_FIFO_WO(x) (((x) >> BIT_SHIFT_DAC0_FIFO_WO) & BIT_MASK_DAC0_FIFO_WO)
|
||||
|
||||
|
||||
//2 REG_DAC_CTRL
|
||||
|
||||
#define BIT_SHIFT_DAC_DELTA_SIGMA 25
|
||||
#define BIT_MASK_DAC_DELTA_SIGMA 0x7
|
||||
#define BIT_DAC_DELTA_SIGMA(x) (((x) & BIT_MASK_DAC_DELTA_SIGMA) << BIT_SHIFT_DAC_DELTA_SIGMA)
|
||||
#define BIT_CTRL_DAC_DELTA_SIGMA(x) (((x) & BIT_MASK_DAC_DELTA_SIGMA) << BIT_SHIFT_DAC_DELTA_SIGMA)
|
||||
#define BIT_GET_DAC_DELTA_SIGMA(x) (((x) >> BIT_SHIFT_DAC_DELTA_SIGMA) & BIT_MASK_DAC_DELTA_SIGMA)
|
||||
|
||||
#define BIT_DAC_BYPASS_DSC BIT(24)
|
||||
#define BIT_SHIFT_DAC_BYPASS_DSC 24
|
||||
#define BIT_MASK_DAC_BYPASS_DSC 0x1
|
||||
#define BIT_CTRL_DAC_BYPASS_DSC(x) (((x) & BIT_MASK_DAC_BYPASS_DSC) << BIT_SHIFT_DAC_BYPASS_DSC)
|
||||
|
||||
|
||||
#define BIT_SHIFT_DAC_DSC_DBG_SEL 19
|
||||
#define BIT_MASK_DAC_DSC_DBG_SEL 0x3
|
||||
#define BIT_DAC_DSC_DBG_SEL(x) (((x) & BIT_MASK_DAC_DSC_DBG_SEL) << BIT_SHIFT_DAC_DSC_DBG_SEL)
|
||||
#define BIT_CTRL_DAC_DSC_DBG_SEL(x) (((x) & BIT_MASK_DAC_DSC_DBG_SEL) << BIT_SHIFT_DAC_DSC_DBG_SEL)
|
||||
#define BIT_GET_DAC_DSC_DBG_SEL(x) (((x) >> BIT_SHIFT_DAC_DSC_DBG_SEL) & BIT_MASK_DAC_DSC_DBG_SEL)
|
||||
|
||||
|
||||
#define BIT_SHIFT_DAC_DBG_SEL 16
|
||||
#define BIT_MASK_DAC_DBG_SEL 0x7
|
||||
#define BIT_DAC_DBG_SEL(x) (((x) & BIT_MASK_DAC_DBG_SEL) << BIT_SHIFT_DAC_DBG_SEL)
|
||||
#define BIT_CTRL_DAC_DBG_SEL(x) (((x) & BIT_MASK_DAC_DBG_SEL) << BIT_SHIFT_DAC_DBG_SEL)
|
||||
#define BIT_GET_DAC_DBG_SEL(x) (((x) >> BIT_SHIFT_DAC_DBG_SEL) & BIT_MASK_DAC_DBG_SEL)
|
||||
|
||||
|
||||
#define BIT_SHIFT_DAC_BURST_SIZE 8
|
||||
#define BIT_MASK_DAC_BURST_SIZE 0xf
|
||||
#define BIT_DAC_BURST_SIZE(x) (((x) & BIT_MASK_DAC_BURST_SIZE) << BIT_SHIFT_DAC_BURST_SIZE)
|
||||
#define BIT_CTRL_DAC_BURST_SIZE(x) (((x) & BIT_MASK_DAC_BURST_SIZE) << BIT_SHIFT_DAC_BURST_SIZE)
|
||||
#define BIT_GET_DAC_BURST_SIZE(x) (((x) >> BIT_SHIFT_DAC_BURST_SIZE) & BIT_MASK_DAC_BURST_SIZE)
|
||||
|
||||
#define BIT_DAC_FILTER_SETTLE BIT(4)
|
||||
#define BIT_SHIFT_DAC_FILTER_SETTLE 4
|
||||
#define BIT_MASK_DAC_FILTER_SETTLE 0x1
|
||||
#define BIT_CTRL_DAC_FILTER_SETTLE(x) (((x) & BIT_MASK_DAC_FILTER_SETTLE) << BIT_SHIFT_DAC_FILTER_SETTLE)
|
||||
|
||||
#define BIT_DAC_OV_OPTION BIT(3)
|
||||
#define BIT_SHIFT_DAC_OV_OPTION 3
|
||||
#define BIT_MASK_DAC_OV_OPTION 0x1
|
||||
#define BIT_CTRL_DAC_OV_OPTION(x) (((x) & BIT_MASK_DAC_OV_OPTION) << BIT_SHIFT_DAC_OV_OPTION)
|
||||
|
||||
#define BIT_DAC_ENDIAN BIT(2)
|
||||
#define BIT_SHIFT_DAC_ENDIAN 2
|
||||
#define BIT_MASK_DAC_ENDIAN 0x1
|
||||
#define BIT_CTRL_DAC_ENDIAN(x) (((x) & BIT_MASK_DAC_ENDIAN) << BIT_SHIFT_DAC_ENDIAN)
|
||||
|
||||
#define BIT_DAC_SPEED BIT(1)
|
||||
#define BIT_SHIFT_DAC_SPEED 1
|
||||
#define BIT_MASK_DAC_SPEED 0x1
|
||||
#define BIT_CTRL_DAC_SPEED(x) (((x) & BIT_MASK_DAC_SPEED) << BIT_SHIFT_DAC_SPEED)
|
||||
|
||||
#define BIT_DAC_FIFO_EN BIT(0)
|
||||
#define BIT_SHIFT_DAC_FIFO_EN 0
|
||||
#define BIT_MASK_DAC_FIFO_EN 0x1
|
||||
#define BIT_CTRL_DAC_FIFO_EN(x) (((x) & BIT_MASK_DAC_FIFO_EN) << BIT_SHIFT_DAC_FIFO_EN)
|
||||
|
||||
|
||||
//2 REG_DAC_INTR_CTRL
|
||||
#define BIT_DAC_DSC_OVERFLOW1_EN BIT(6)
|
||||
#define BIT_SHIFT_DAC_DSC_OVERFLOW1_EN 6
|
||||
#define BIT_MASK_DAC_DSC_OVERFLOW1_EN 0x1
|
||||
#define BIT_CTRL_DAC_DSC_OVERFLOW1_EN(x) (((x) & BIT_MASK_DAC_DSC_OVERFLOW1_EN) << BIT_SHIFT_DAC_DSC_OVERFLOW1_EN)
|
||||
|
||||
#define BIT_DAC_DSC_OVERFLOW0_EN BIT(5)
|
||||
#define BIT_SHIFT_DAC_DSC_OVERFLOW0_EN 5
|
||||
#define BIT_MASK_DAC_DSC_OVERFLOW0_EN 0x1
|
||||
#define BIT_CTRL_DAC_DSC_OVERFLOW0_EN(x) (((x) & BIT_MASK_DAC_DSC_OVERFLOW0_EN) << BIT_SHIFT_DAC_DSC_OVERFLOW0_EN)
|
||||
|
||||
#define BIT_DAC__WRITE_ERROR_EN BIT(4)
|
||||
#define BIT_SHIFT_DAC__WRITE_ERROR_EN 4
|
||||
#define BIT_MASK_DAC__WRITE_ERROR_EN 0x1
|
||||
#define BIT_CTRL_DAC__WRITE_ERROR_EN(x) (((x) & BIT_MASK_DAC__WRITE_ERROR_EN) << BIT_SHIFT_DAC__WRITE_ERROR_EN)
|
||||
|
||||
#define BIT_DAC_FIFO_STOP_EN BIT(3)
|
||||
#define BIT_SHIFT_DAC_FIFO_STOP_EN 3
|
||||
#define BIT_MASK_DAC_FIFO_STOP_EN 0x1
|
||||
#define BIT_CTRL_DAC_FIFO_STOP_EN(x) (((x) & BIT_MASK_DAC_FIFO_STOP_EN) << BIT_SHIFT_DAC_FIFO_STOP_EN)
|
||||
|
||||
#define BIT_DAC_FIFO_OVERFLOW_EN BIT(2)
|
||||
#define BIT_SHIFT_DAC_FIFO_OVERFLOW_EN 2
|
||||
#define BIT_MASK_DAC_FIFO_OVERFLOW_EN 0x1
|
||||
#define BIT_CTRL_DAC_FIFO_OVERFLOW_EN(x) (((x) & BIT_MASK_DAC_FIFO_OVERFLOW_EN) << BIT_SHIFT_DAC_FIFO_OVERFLOW_EN)
|
||||
|
||||
#define BIT_DAC_FIFO_WR_REQ_EN BIT(1)
|
||||
#define BIT_SHIFT_DAC_FIFO_WR_REQ_EN 1
|
||||
#define BIT_MASK_DAC_FIFO_WR_REQ_EN 0x1
|
||||
#define BIT_CTRL_DAC_FIFO_WR_REQ_EN(x) (((x) & BIT_MASK_DAC_FIFO_WR_REQ_EN) << BIT_SHIFT_DAC_FIFO_WR_REQ_EN)
|
||||
|
||||
#define BIT_DAC_FIFO_FULL_EN BIT(0)
|
||||
#define BIT_SHIFT_DAC_FIFO_FULL_EN 0
|
||||
#define BIT_MASK_DAC_FIFO_FULL_EN 0x1
|
||||
#define BIT_CTRL_DAC_FIFO_FULL_EN(x) (((x) & BIT_MASK_DAC_FIFO_FULL_EN) << BIT_SHIFT_DAC_FIFO_FULL_EN)
|
||||
|
||||
|
||||
//2 REG_DAC_INTR_STS
|
||||
#define BIT_DAC_DSC_OVERFLOW1_ST BIT(6)
|
||||
#define BIT_SHIFT_DAC_DSC_OVERFLOW1_ST 6
|
||||
#define BIT_MASK_DAC_DSC_OVERFLOW1_ST 0x1
|
||||
#define BIT_CTRL_DAC_DSC_OVERFLOW1_ST(x) (((x) & BIT_MASK_DAC_DSC_OVERFLOW1_ST) << BIT_SHIFT_DAC_DSC_OVERFLOW1_ST)
|
||||
|
||||
#define BIT_DAC_DSC_OVERFLOW0_ST BIT(5)
|
||||
#define BIT_SHIFT_DAC_DSC_OVERFLOW0_ST 5
|
||||
#define BIT_MASK_DAC_DSC_OVERFLOW0_ST 0x1
|
||||
#define BIT_CTRL_DAC_DSC_OVERFLOW0_ST(x) (((x) & BIT_MASK_DAC_DSC_OVERFLOW0_ST) << BIT_SHIFT_DAC_DSC_OVERFLOW0_ST)
|
||||
|
||||
#define BIT_DAC__WRITE_ERROR_ST BIT(4)
|
||||
#define BIT_SHIFT_DAC__WRITE_ERROR_ST 4
|
||||
#define BIT_MASK_DAC__WRITE_ERROR_ST 0x1
|
||||
#define BIT_CTRL_DAC__WRITE_ERROR_ST(x) (((x) & BIT_MASK_DAC__WRITE_ERROR_ST) << BIT_SHIFT_DAC__WRITE_ERROR_ST)
|
||||
|
||||
#define BIT_DAC_FIFO_STOP_ST BIT(3)
|
||||
#define BIT_SHIFT_DAC_FIFO_STOP_ST 3
|
||||
#define BIT_MASK_DAC_FIFO_STOP_ST 0x1
|
||||
#define BIT_CTRL_DAC_FIFO_STOP_ST(x) (((x) & BIT_MASK_DAC_FIFO_STOP_ST) << BIT_SHIFT_DAC_FIFO_STOP_ST)
|
||||
|
||||
#define BIT_DAC_FIFO_OVERFLOW_ST BIT(2)
|
||||
#define BIT_SHIFT_DAC_FIFO_OVERFLOW_ST 2
|
||||
#define BIT_MASK_DAC_FIFO_OVERFLOW_ST 0x1
|
||||
#define BIT_CTRL_DAC_FIFO_OVERFLOW_ST(x) (((x) & BIT_MASK_DAC_FIFO_OVERFLOW_ST) << BIT_SHIFT_DAC_FIFO_OVERFLOW_ST)
|
||||
|
||||
#define BIT_DAC_FIFO_WR_REQ_ST BIT(1)
|
||||
#define BIT_SHIFT_DAC_FIFO_WR_REQ_ST 1
|
||||
#define BIT_MASK_DAC_FIFO_WR_REQ_ST 0x1
|
||||
#define BIT_CTRL_DAC_FIFO_WR_REQ_ST(x) (((x) & BIT_MASK_DAC_FIFO_WR_REQ_ST) << BIT_SHIFT_DAC_FIFO_WR_REQ_ST)
|
||||
|
||||
#define BIT_DAC_FIFO_FULL_ST BIT(0)
|
||||
#define BIT_SHIFT_DAC_FIFO_FULL_ST 0
|
||||
#define BIT_MASK_DAC_FIFO_FULL_ST 0x1
|
||||
#define BIT_CTRL_DAC_FIFO_FULL_ST(x) (((x) & BIT_MASK_DAC_FIFO_FULL_ST) << BIT_SHIFT_DAC_FIFO_FULL_ST)
|
||||
|
||||
|
||||
//2 REG_DAC_PWR_CTRL
|
||||
|
||||
#define BIT_SHIFT_DAC_PWR_CUT_CNTR 16
|
||||
#define BIT_MASK_DAC_PWR_CUT_CNTR 0xff
|
||||
#define BIT_DAC_PWR_CUT_CNTR(x) (((x) & BIT_MASK_DAC_PWR_CUT_CNTR) << BIT_SHIFT_DAC_PWR_CUT_CNTR)
|
||||
#define BIT_CTRL_DAC_PWR_CUT_CNTR(x) (((x) & BIT_MASK_DAC_PWR_CUT_CNTR) << BIT_SHIFT_DAC_PWR_CUT_CNTR)
|
||||
#define BIT_GET_DAC_PWR_CUT_CNTR(x) (((x) >> BIT_SHIFT_DAC_PWR_CUT_CNTR) & BIT_MASK_DAC_PWR_CUT_CNTR)
|
||||
|
||||
#define BIT_ST_DAC_FIFO_ON BIT(11)
|
||||
#define BIT_SHIFT_ST_DAC_FIFO_ON 11
|
||||
#define BIT_MASK_ST_DAC_FIFO_ON 0x1
|
||||
#define BIT_CTRL_ST_DAC_FIFO_ON(x) (((x) & BIT_MASK_ST_DAC_FIFO_ON) << BIT_SHIFT_ST_DAC_FIFO_ON)
|
||||
|
||||
#define BIT_ST_DAC_ISO_ON BIT(10)
|
||||
#define BIT_SHIFT_ST_DAC_ISO_ON 10
|
||||
#define BIT_MASK_ST_DAC_ISO_ON 0x1
|
||||
#define BIT_CTRL_ST_DAC_ISO_ON(x) (((x) & BIT_MASK_ST_DAC_ISO_ON) << BIT_SHIFT_ST_DAC_ISO_ON)
|
||||
|
||||
#define BIT_ST_DAC_PWR33_ON BIT(9)
|
||||
#define BIT_SHIFT_ST_DAC_PWR33_ON 9
|
||||
#define BIT_MASK_ST_DAC_PWR33_ON 0x1
|
||||
#define BIT_CTRL_ST_DAC_PWR33_ON(x) (((x) & BIT_MASK_ST_DAC_PWR33_ON) << BIT_SHIFT_ST_DAC_PWR33_ON)
|
||||
|
||||
#define BIT_ST_DAC_PWR12_ON BIT(8)
|
||||
#define BIT_SHIFT_ST_DAC_PWR12_ON 8
|
||||
#define BIT_MASK_ST_DAC_PWR12_ON 0x1
|
||||
#define BIT_CTRL_ST_DAC_PWR12_ON(x) (((x) & BIT_MASK_ST_DAC_PWR12_ON) << BIT_SHIFT_ST_DAC_PWR12_ON)
|
||||
|
||||
#define BIT_DAC_ISO_MANU BIT(3)
|
||||
#define BIT_SHIFT_DAC_ISO_MANU 3
|
||||
#define BIT_MASK_DAC_ISO_MANU 0x1
|
||||
#define BIT_CTRL_DAC_ISO_MANU(x) (((x) & BIT_MASK_DAC_ISO_MANU) << BIT_SHIFT_DAC_ISO_MANU)
|
||||
|
||||
#define BIT_DAC_PWR33_MANU BIT(2)
|
||||
#define BIT_SHIFT_DAC_PWR33_MANU 2
|
||||
#define BIT_MASK_DAC_PWR33_MANU 0x1
|
||||
#define BIT_CTRL_DAC_PWR33_MANU(x) (((x) & BIT_MASK_DAC_PWR33_MANU) << BIT_SHIFT_DAC_PWR33_MANU)
|
||||
|
||||
#define BIT_DAC_PWR12_MANU BIT(1)
|
||||
#define BIT_SHIFT_DAC_PWR12_MANU 1
|
||||
#define BIT_MASK_DAC_PWR12_MANU 0x1
|
||||
#define BIT_CTRL_DAC_PWR12_MANU(x) (((x) & BIT_MASK_DAC_PWR12_MANU) << BIT_SHIFT_DAC_PWR12_MANU)
|
||||
|
||||
#define BIT_DAC_PWR_AUTO BIT(0)
|
||||
#define BIT_SHIFT_DAC_PWR_AUTO 0
|
||||
#define BIT_MASK_DAC_PWR_AUTO 0x1
|
||||
#define BIT_CTRL_DAC_PWR_AUTO(x) (((x) & BIT_MASK_DAC_PWR_AUTO) << BIT_SHIFT_DAC_PWR_AUTO)
|
||||
|
||||
|
||||
//2 REG_DAC_ANAPAR_DA0
|
||||
|
||||
#define BIT_SHIFT_PWR_ALL_CNTR 12
|
||||
#define BIT_MASK_PWR_ALL_CNTR 0xfffff
|
||||
#define BIT_PWR_ALL_CNTR(x) (((x) & BIT_MASK_PWR_ALL_CNTR) << BIT_SHIFT_PWR_ALL_CNTR)
|
||||
#define BIT_CTRL_PWR_ALL_CNTR(x) (((x) & BIT_MASK_PWR_ALL_CNTR) << BIT_SHIFT_PWR_ALL_CNTR)
|
||||
#define BIT_GET_PWR_ALL_CNTR(x) (((x) >> BIT_SHIFT_PWR_ALL_CNTR) & BIT_MASK_PWR_ALL_CNTR)
|
||||
|
||||
|
||||
#define BIT_SHIFT_PWR_FUP_CNTR 0
|
||||
#define BIT_MASK_PWR_FUP_CNTR 0xfff
|
||||
#define BIT_PWR_FUP_CNTR(x) (((x) & BIT_MASK_PWR_FUP_CNTR) << BIT_SHIFT_PWR_FUP_CNTR)
|
||||
#define BIT_CTRL_PWR_FUP_CNTR(x) (((x) & BIT_MASK_PWR_FUP_CNTR) << BIT_SHIFT_PWR_FUP_CNTR)
|
||||
#define BIT_GET_PWR_FUP_CNTR(x) (((x) >> BIT_SHIFT_PWR_FUP_CNTR) & BIT_MASK_PWR_FUP_CNTR)
|
||||
|
||||
|
||||
//2 REG_DAC_ANAPAR_DA1
|
||||
#define BIT_FUP_EN BIT(31)
|
||||
#define BIT_SHIFT_FUP_EN 31
|
||||
#define BIT_MASK_FUP_EN 0x1
|
||||
#define BIT_CTRL_FUP_EN(x) (((x) & BIT_MASK_FUP_EN) << BIT_SHIFT_FUP_EN)
|
||||
|
||||
|
||||
#define BIT_SHIFT_ANAPAR_DA 8
|
||||
#define BIT_MASK_ANAPAR_DA 0x7fffff
|
||||
#define BIT_ANAPAR_DA(x) (((x) & BIT_MASK_ANAPAR_DA) << BIT_SHIFT_ANAPAR_DA)
|
||||
#define BIT_CTRL_ANAPAR_DA(x) (((x) & BIT_MASK_ANAPAR_DA) << BIT_SHIFT_ANAPAR_DA)
|
||||
#define BIT_GET_ANAPAR_DA(x) (((x) >> BIT_SHIFT_ANAPAR_DA) & BIT_MASK_ANAPAR_DA)
|
||||
|
||||
#define BIT_D_POW_DACVREF BIT(7)
|
||||
#define BIT_SHIFT_D_POW_DACVREF 7
|
||||
#define BIT_MASK_D_POW_DACVREF 0x1
|
||||
#define BIT_CTRL_D_POW_DACVREF(x) (((x) & BIT_MASK_D_POW_DACVREF) << BIT_SHIFT_D_POW_DACVREF)
|
||||
|
||||
#define BIT_D_POW_VREF2 BIT(6)
|
||||
#define BIT_SHIFT_D_POW_VREF2 6
|
||||
#define BIT_MASK_D_POW_VREF2 0x1
|
||||
#define BIT_CTRL_D_POW_VREF2(x) (((x) & BIT_MASK_D_POW_VREF2) << BIT_SHIFT_D_POW_VREF2)
|
||||
|
||||
#define BIT_D_POW_MBIAS BIT(5)
|
||||
#define BIT_SHIFT_D_POW_MBIAS 5
|
||||
#define BIT_MASK_D_POW_MBIAS 0x1
|
||||
#define BIT_CTRL_D_POW_MBIAS(x) (((x) & BIT_MASK_D_POW_MBIAS) << BIT_SHIFT_D_POW_MBIAS)
|
||||
|
||||
#define BIT_D_POW_DIV4 BIT(4)
|
||||
#define BIT_SHIFT_D_POW_DIV4 4
|
||||
#define BIT_MASK_D_POW_DIV4 0x1
|
||||
#define BIT_CTRL_D_POW_DIV4(x) (((x) & BIT_MASK_D_POW_DIV4) << BIT_SHIFT_D_POW_DIV4)
|
||||
|
||||
#define BIT_D_POW_DF1SE_R BIT(3)
|
||||
#define BIT_SHIFT_D_POW_DF1SE_R 3
|
||||
#define BIT_MASK_D_POW_DF1SE_R 0x1
|
||||
#define BIT_CTRL_D_POW_DF1SE_R(x) (((x) & BIT_MASK_D_POW_DF1SE_R) << BIT_SHIFT_D_POW_DF1SE_R)
|
||||
|
||||
#define BIT_D_POW_DF2SE_L BIT(2)
|
||||
#define BIT_SHIFT_D_POW_DF2SE_L 2
|
||||
#define BIT_MASK_D_POW_DF2SE_L 0x1
|
||||
#define BIT_CTRL_D_POW_DF2SE_L(x) (((x) & BIT_MASK_D_POW_DF2SE_L) << BIT_SHIFT_D_POW_DF2SE_L)
|
||||
|
||||
#define BIT_D_POW_DAC_R BIT(1)
|
||||
#define BIT_SHIFT_D_POW_DAC_R 1
|
||||
#define BIT_MASK_D_POW_DAC_R 0x1
|
||||
#define BIT_CTRL_D_POW_DAC_R(x) (((x) & BIT_MASK_D_POW_DAC_R) << BIT_SHIFT_D_POW_DAC_R)
|
||||
|
||||
#define BIT_D_POW_DAC_L BIT(0)
|
||||
#define BIT_SHIFT_D_POW_DAC_L 0
|
||||
#define BIT_MASK_D_POW_DAC_L 0x1
|
||||
#define BIT_CTRL_D_POW_DAC_L(x) (((x) & BIT_MASK_D_POW_DAC_L) << BIT_SHIFT_D_POW_DAC_L)
|
||||
|
||||
|
||||
//================ Register Reg Field =========================
|
||||
#define REG_DAC0_FIFO_WR 0x0000
|
||||
#define REG_DAC_CTRL 0x0004
|
||||
#define REG_DAC_INTR_CTRL 0x0008
|
||||
#define REG_DAC_INTR_STS 0x000C
|
||||
#define REG_DAC_PWR_CTRL 0x0010
|
||||
#define REG_DAC_ANAPAR_DA0 0x0014
|
||||
#define REG_DAC_ANAPAR_DA1 0x0018
|
||||
|
||||
|
||||
//================ DAC HAL related enumeration ==================
|
||||
|
||||
|
||||
//================ DAC HAL Macro ===========================
|
||||
#define HAL_DAC_WRITE32(dacidx, addr, value) HAL_WRITE32(DAC_REG_BASE+dacidx*0x800 \
|
||||
,addr,value)
|
||||
#define HAL_DAC_READ32(dacidx, addr) HAL_READ32(DAC_REG_BASE+dacidx*0x800,addr)
|
||||
|
||||
|
||||
//================ DAC Function Prototypes =====================
|
||||
RTK_STATUS HalDACInit8195a(IN void *Data);
|
||||
RTK_STATUS HalDACDeInit8195a(IN void *Data);
|
||||
RTK_STATUS HalDACEnableRtl8195a(IN void *Data);
|
||||
RTK_STATUS HalDACIntrCtrl8195a(IN void *Data);
|
||||
uint8_t HalDACSendRtl8195a(IN void *Data);
|
||||
uint32_t HalDACReadRegRtl8195a(IN void *Data,IN uint8_t I2CReg);
|
||||
|
||||
#endif
|
||||
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