1506 lines
46 KiB
C
1506 lines
46 KiB
C
|
/****************************************************************************
|
||
|
|
||
|
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
|
||
|
|
||
|
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
|
||
|
be copied by any method or incorporated into another program without
|
||
|
the express written consent of Aerospace C.Power. This Information or any portion
|
||
|
thereof remains the property of Aerospace C.Power. The Information contained herein
|
||
|
is believed to be accurate and Aerospace C.Power assumes no responsibility or
|
||
|
liability for its use in any way and conveys no license or title under
|
||
|
any patent or copyright and makes no representation or warranty that this
|
||
|
Information is free from patent or copyright infringement.
|
||
|
|
||
|
****************************************************************************/
|
||
|
/* common includes */
|
||
|
#include "os_types.h"
|
||
|
#include "os_mem.h"
|
||
|
#include "iot_irq.h"
|
||
|
#include "iot_errno.h"
|
||
|
#include "hw_desc.h"
|
||
|
#include "mpdu_frame.h"
|
||
|
#include "mac_sys_reg.h"
|
||
|
#include "mac_raw_reg.h"
|
||
|
#include "phy_reg.h"
|
||
|
#include "hw_reg_api.h"
|
||
|
#include "rawdata_test.h"
|
||
|
#include "dbg_io.h"
|
||
|
#include "iot_io.h"
|
||
|
#include "uart.h"
|
||
|
#include "gpio_mtx.h"
|
||
|
#include "plc_protocol.h"
|
||
|
|
||
|
//#define IPC_CONTROL 1
|
||
|
|
||
|
//#define DUMP_TIMING 1
|
||
|
|
||
|
//#define ENABLE_PRINT 1
|
||
|
|
||
|
#ifdef IPC_CONTROL
|
||
|
#include "iot_mc_ipc.h"
|
||
|
#endif
|
||
|
|
||
|
rawdata_context g_rawdata;
|
||
|
|
||
|
/* irq defination */
|
||
|
|
||
|
#define IRQ_NUM_MAC_TXFC HAL_VECTOR_MAC_2
|
||
|
#define IRQ_NUM_MAC_TXSACK_FC HAL_VECTOR_MAC_3
|
||
|
|
||
|
#define IRQ_NUM_PHY_REC_FC HAL_VECTOR_PHY_1
|
||
|
#define IRQ_NUM_PHY_RECFC_TIMEOUT HAL_VECTOR_PHY_2
|
||
|
#define IRQ_NUM_PHY_TXFC_TIMEOUT HAL_VECTOR_PHY_3
|
||
|
|
||
|
|
||
|
#define INTR_TYPE_MAC_TX_FC 0x01
|
||
|
#define INTR_TYPE_MAC_TX_SACK_FC 0x02
|
||
|
#define INTR_TYPE_PHY_RECV_FC 0x04
|
||
|
#define INTR_TYPE_PHY_RECV_FC_TIMOUT 0x08
|
||
|
#define INTR_TYPE_PHY_TX_FC_TIMEOUT 0x10
|
||
|
#define INTR_TYPE_RAW_ALL 0x1F
|
||
|
|
||
|
#define INTR_TYPE_TIMEOUT_ERR 0x18
|
||
|
|
||
|
#define MAC_TX_FC_MASK 0x1 //bit0
|
||
|
#define MAC_TX_SACK_FC_MASK 0x2 //bit1
|
||
|
|
||
|
#define PHY_RECV_FC_MASK 0x40000000 //bit 30
|
||
|
#define PHY_RECV_FC_TIMEOUT 0x8000 //bit 15
|
||
|
#define PHY_RECV_TX_FC_TIMEOUT 0x1000 //bit 12
|
||
|
|
||
|
|
||
|
static iot_irq_t mac_txfc_irqhdl;
|
||
|
static iot_irq_t mac_txsackfc_irqhdl;
|
||
|
|
||
|
static iot_irq_t phy_recfc_irqhdl;
|
||
|
static iot_irq_t phy_recfc_timeouthdl;
|
||
|
static iot_irq_t phy_txfc_timeouthdl;
|
||
|
|
||
|
uint32_t iot_rawdata_soc_attach_isr(void);
|
||
|
uint32_t iot_rawdata_soc_deattach_isr(void);
|
||
|
uint32_t iot_rawdata_soc_enable_all_isr(void);
|
||
|
uint32_t iot_rawdata_soc_disable_all_isr(void);
|
||
|
uint32_t iot_rawdata_soc_enable_isr(uint8_t irqnum);
|
||
|
uint32_t iot_rawdata_soc_disable_isr(uint8_t irqnum);
|
||
|
|
||
|
|
||
|
|
||
|
static void iot_rawdata_set_crc(fc_trans_msg *rawfc);
|
||
|
static uint32_t iot_rawdata_valid_crc(fc_trans_msg *rawfc);
|
||
|
|
||
|
void uart_gpio_sel();
|
||
|
|
||
|
|
||
|
#ifdef IPC_CONTROL
|
||
|
|
||
|
#define IPC_MSG_ID_RAWDATA_START_REQ 1
|
||
|
|
||
|
#define REQ_TYPE_NEW 1
|
||
|
|
||
|
|
||
|
typedef struct _ipc_msg_rawdata_start_req
|
||
|
{
|
||
|
uint8_t req_type;
|
||
|
}ipc_msg_rawdata_start_req_t;
|
||
|
|
||
|
|
||
|
#define IPC_MSG_ID_RAWDATA_START_CNF 2
|
||
|
|
||
|
|
||
|
#define CNF_STATUS_OK 1
|
||
|
#define CNF_STATUS_FAIL 2
|
||
|
typedef struct _ipc_msg_rawdata_start_cnf
|
||
|
{
|
||
|
uint8_t status;
|
||
|
}ipc_msg_rawdata_cnf_t;
|
||
|
|
||
|
|
||
|
ipc_msg_rawdata_start_req_t start_msg;
|
||
|
ipc_msg_rawdata_cnf_t cnf_msg;
|
||
|
|
||
|
volatile uint32_t rawdata_cnf_received = 0;
|
||
|
volatile uint32_t rawdata_start_received = 0;
|
||
|
|
||
|
void scpu_recv_ipc_msg(uint32_t msg_id, void* msg_arg);
|
||
|
void acpu_recv_ipc_msg(uint32_t msg_id, void* msg_arg);
|
||
|
|
||
|
|
||
|
uint32_t iot_rawdata_init_ipc(uint8_t cpuid)
|
||
|
{
|
||
|
if(cpuid == IOT_SECCPU_ID){
|
||
|
iot_mc_ipc_init(scpu_recv_ipc_msg, IOT_SECCPU_ID, INTC_MODE);
|
||
|
}else{
|
||
|
iot_mc_ipc_init(acpu_recv_ipc_msg, IOT_APPCPU_ID, INTC_MODE);
|
||
|
}
|
||
|
|
||
|
return ERR_OK;
|
||
|
}
|
||
|
|
||
|
|
||
|
uint32_t acpu_start_rawdata(void)
|
||
|
{
|
||
|
uint32_t j = 0;
|
||
|
start_msg.req_type = REQ_TYPE_NEW;
|
||
|
|
||
|
while(!rawdata_cnf_received){
|
||
|
if(iot_mc_ipc_query_mailbox_freecredit() >0){
|
||
|
iot_mc_ipc_send_msg(IPC_MSG_ID_RAWDATA_START_REQ, (void*)&start_msg);
|
||
|
}
|
||
|
|
||
|
for(j=0;j<APP_CPU_POLL_SPEED;j++);
|
||
|
|
||
|
for(j=0;j<APP_CPU_POLL_SPEED;j++);
|
||
|
|
||
|
for(j=0;j<APP_CPU_POLL_SPEED;j++);
|
||
|
}
|
||
|
return ERR_OK;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
void acpu_recv_ipc_msg(uint32_t msg_id, void* msg_arg)
|
||
|
{
|
||
|
|
||
|
ipc_msg_rawdata_cnf_t* pmsg = NULL;
|
||
|
|
||
|
iot_printf("secpu[rec] msg_id:%x arg:%xstatus:%x\n", msg_id, msg_arg, iot_mc_ipc_get_hw_stauts());
|
||
|
switch(msg_id)
|
||
|
{
|
||
|
case IPC_MSG_ID_RAWDATA_START_CNF:
|
||
|
pmsg = (ipc_msg_rawdata_cnf_t*)msg_arg;
|
||
|
iot_printf("IPC_MSG_ID_RAWDATA_START_CNF : %d\n", pmsg->status);
|
||
|
if(pmsg->status == CNF_STATUS_OK){
|
||
|
rawdata_cnf_received = 1;
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
|
||
|
default:
|
||
|
iot_printf("unhandled msgid:0x%x\n", msg_id);
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
void scpu_recv_ipc_msg(uint32_t msg_id, void* msg_arg)
|
||
|
{
|
||
|
ipc_msg_rawdata_start_req_t* pmsg = NULL;
|
||
|
|
||
|
iot_printf("secpu[rec] msg_id %x arg:%x status:%x\n", msg_id, msg_arg, iot_mc_ipc_get_hw_stauts());
|
||
|
switch(msg_id)
|
||
|
{
|
||
|
case IPC_MSG_ID_RAWDATA_START_REQ:
|
||
|
pmsg = (ipc_msg_rawdata_start_req_t*)msg_arg;
|
||
|
iot_printf("IPC_MSG_ID_RAWDATA_START_REQ : %d\n", pmsg->req_type);
|
||
|
cnf_msg.status = CNF_STATUS_OK;
|
||
|
if(!rawdata_start_received){
|
||
|
if(iot_mc_ipc_query_mailbox_freecredit() >0){
|
||
|
iot_mc_ipc_send_msg(IPC_MSG_ID_RAWDATA_START_CNF, (void*)&cnf_msg);
|
||
|
rawdata_start_received = 1;
|
||
|
iot_printf("start received : %d\n", rawdata_start_received);
|
||
|
}
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
|
||
|
default:
|
||
|
iot_printf("unhandled msgid:0x%x\n", msg_id);
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* acpu will send ipc request to scpu to start rawmode */
|
||
|
|
||
|
#endif
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
static void iot_rawdata_set_crc(fc_trans_msg *rawfc)
|
||
|
{
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
static uint32_t iot_rawdata_valid_crc(fc_trans_msg *rawfc)
|
||
|
{
|
||
|
return ERR_OK;
|
||
|
}
|
||
|
|
||
|
#define RAW_REG_TYPE_MAC 1
|
||
|
#define RAW_REG_TYPE_PHY 2
|
||
|
uint32_t iot_raw_read_reg(uint32_t type, uint32_t addr)
|
||
|
{
|
||
|
uint32_t val = 0;
|
||
|
if(type == RAW_REG_TYPE_MAC){
|
||
|
val = RGF_RAW_READ_REG(addr);
|
||
|
#ifdef ENABLE_PRINT
|
||
|
iot_printf("raw_mac_read 0x%x=0x%x\n", addr, val);
|
||
|
#endif
|
||
|
}else if(type == RAW_REG_TYPE_PHY){
|
||
|
val = PHY_READ_REG(addr);
|
||
|
#ifdef ENABLE_PRINT
|
||
|
iot_printf("raw_phy_read 0x%x=0x%x\n", addr, val);
|
||
|
#endif
|
||
|
}
|
||
|
|
||
|
return val;
|
||
|
}
|
||
|
|
||
|
void iot_raw_write_reg(uint32_t type, uint32_t addr, uint32_t val)
|
||
|
{
|
||
|
|
||
|
if(type == RAW_REG_TYPE_MAC){
|
||
|
RGF_RAW_WRITE_REG(addr,val);
|
||
|
#ifdef ENABLE_PRINT
|
||
|
iot_printf("raw_mac_write 0x%x=0x%x\n", addr, val);
|
||
|
#endif
|
||
|
}else if(type == RAW_REG_TYPE_PHY){
|
||
|
#ifdef ENABLE_PRINT
|
||
|
iot_printf("raw_phy_write 0x%x=0x%x\n", addr, val);
|
||
|
#endif
|
||
|
PHY_WRITE_REG(addr, val);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
typedef struct _fc_profile{
|
||
|
uint32_t rawdata_interrupt_trigger_ticks;
|
||
|
uint32_t rawdata_get_fc_ticks;
|
||
|
uint32_t rawdata_translate_fc_ticks;
|
||
|
uint32_t rawdata_set_translate_fc_ticks;
|
||
|
uint32_t rawdata_interrupt_release_ticks;
|
||
|
}fc_profile;
|
||
|
*/
|
||
|
|
||
|
void iot_raw_dump_analysis(uint32_t irq_type)
|
||
|
{
|
||
|
uint32_t idx = 0;
|
||
|
fc_trans_msg* trans_msg = NULL;
|
||
|
uint32_t d1, d2, d3, d4, d5;
|
||
|
|
||
|
|
||
|
if(irq_type & INTR_TYPE_MAC_TX_FC){
|
||
|
trans_msg = g_rawdata.tx_msg;
|
||
|
}
|
||
|
|
||
|
if(irq_type & INTR_TYPE_MAC_TX_SACK_FC){
|
||
|
trans_msg = g_rawdata.ack_msg;
|
||
|
}
|
||
|
|
||
|
if(irq_type & INTR_TYPE_PHY_RECV_FC){
|
||
|
trans_msg = g_rawdata.rec_msg;
|
||
|
}
|
||
|
|
||
|
iot_printf("Dump2 timing irq_type:%x\n", irq_type);
|
||
|
for(idx = 0; idx<RAWDATA_PROFILE_SLOT_MAX;idx++){
|
||
|
iot_printf("irq_in:0x%04x get:0x%04x trans:0x%04x set:0x%04x irq_out:0x%04x irqtype:%x\n",
|
||
|
trans_msg[idx].profile.rawdata_interrupt_trigger_ticks,
|
||
|
trans_msg[idx].profile.rawdata_get_fc_ticks,
|
||
|
trans_msg[idx].profile.rawdata_translate_fc_ticks,
|
||
|
trans_msg[idx].profile.rawdata_set_translate_fc_ticks,
|
||
|
trans_msg[idx].profile.rawdata_interrupt_release_ticks,
|
||
|
trans_msg[idx].profile.irq_type
|
||
|
);
|
||
|
d1 = (trans_msg[idx].profile.rawdata_get_fc_ticks-trans_msg[idx].profile.rawdata_interrupt_trigger_ticks);
|
||
|
d2 = (trans_msg[idx].profile.rawdata_translate_fc_ticks - trans_msg[idx].profile.rawdata_get_fc_ticks);
|
||
|
d3 = (trans_msg[idx].profile.rawdata_set_translate_fc_ticks- trans_msg[idx].profile.rawdata_translate_fc_ticks);
|
||
|
d4 = (trans_msg[idx].profile.rawdata_interrupt_release_ticks - trans_msg[idx].profile.rawdata_set_translate_fc_ticks);
|
||
|
d5 = (trans_msg[idx].profile.rawdata_interrupt_release_ticks - trans_msg[idx].profile.rawdata_interrupt_trigger_ticks);
|
||
|
iot_printf("delta: %d(ticks) %d(ticks) %d(ticks) %d(ticks) %d(ticks)\n",d1, d2, d3, d4, d5);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
void iot_clear_hw_interrupt(uint32_t irq_type)
|
||
|
{
|
||
|
uint32_t reg_int_clear = 0;
|
||
|
uint32_t reg_int = 0;
|
||
|
#ifdef ENABLE_PRINT
|
||
|
iot_printf("iot_clear_hw_interrupt 0x%x\n",irq_type);
|
||
|
#endif
|
||
|
|
||
|
if(irq_type & (INTR_TYPE_MAC_TX_FC|INTR_TYPE_MAC_TX_SACK_FC)){
|
||
|
|
||
|
if(irq_type & INTR_TYPE_MAC_TX_FC){
|
||
|
reg_int_clear = iot_raw_read_reg(RAW_REG_TYPE_MAC,CFG_RAW_INT_CLR_ADDR);
|
||
|
reg_int_clear|=MAC_TX_FC_MASK;
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_MAC,CFG_RAW_INT_CLR_ADDR, reg_int_clear);
|
||
|
}
|
||
|
|
||
|
if(irq_type & INTR_TYPE_MAC_TX_SACK_FC){
|
||
|
reg_int_clear = iot_raw_read_reg(RAW_REG_TYPE_MAC,CFG_RAW_INT_CLR_ADDR);
|
||
|
reg_int_clear |= MAC_TX_SACK_FC_MASK;
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_MAC,CFG_RAW_INT_CLR_ADDR, reg_int_clear);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if(irq_type & (INTR_TYPE_PHY_RECV_FC|INTR_TYPE_PHY_RECV_FC_TIMOUT|INTR_TYPE_PHY_TX_FC_TIMEOUT)){
|
||
|
if(irq_type & INTR_TYPE_PHY_RECV_FC){
|
||
|
reg_int = iot_raw_read_reg(RAW_REG_TYPE_PHY,CFG_BB_INT_CLR_1_ADDR);
|
||
|
reg_int |= PHY_RECV_FC_MASK;
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_PHY,CFG_BB_INT_CLR_1_ADDR, reg_int);
|
||
|
}
|
||
|
|
||
|
if(irq_type & INTR_TYPE_PHY_RECV_FC_TIMOUT){
|
||
|
reg_int = iot_raw_read_reg(RAW_REG_TYPE_PHY,CFG_BB_INT_CLR_2_ADDR);
|
||
|
reg_int |=PHY_RECV_FC_TIMEOUT;
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_PHY,CFG_BB_INT_CLR_2_ADDR, reg_int);
|
||
|
}
|
||
|
|
||
|
if(irq_type & INTR_TYPE_PHY_TX_FC_TIMEOUT){
|
||
|
reg_int = iot_raw_read_reg(RAW_REG_TYPE_PHY,CFG_BB_INT_CLR_3_ADDR);
|
||
|
reg_int |=PHY_RECV_TX_FC_TIMEOUT;
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_PHY,CFG_BB_INT_CLR_3_ADDR, reg_int);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
void iot_disable_hw_interrupt(uint32_t irq_type)
|
||
|
{
|
||
|
int32_t reg_int = 0;
|
||
|
uint32_t reg_intr_en = 0;
|
||
|
fc_trans_msg* pmsg = NULL;
|
||
|
#ifdef ENABLE_PRINT
|
||
|
iot_printf("iot_disable_hw_interrupt:%x\n", irq_type);
|
||
|
#endif
|
||
|
|
||
|
g_rawdata.subfunc_exe_flag = 0x1;
|
||
|
/* handle mac intr */
|
||
|
if(irq_type & (INTR_TYPE_MAC_TX_FC|INTR_TYPE_MAC_TX_SACK_FC)){
|
||
|
|
||
|
g_rawdata.subfunc_exe_flag |= 0x2;
|
||
|
reg_intr_en = iot_raw_read_reg(RAW_REG_TYPE_MAC,CFG_RAW_INT_ENA_ADDR);
|
||
|
g_rawdata.subfunc_exe_flag |= 0x4;
|
||
|
if(irq_type & INTR_TYPE_MAC_TX_FC){
|
||
|
reg_intr_en &= (~MAC_TX_FC_MASK);
|
||
|
}
|
||
|
|
||
|
if(irq_type & INTR_TYPE_MAC_TX_SACK_FC){
|
||
|
reg_intr_en &= (~MAC_TX_SACK_FC_MASK);
|
||
|
}
|
||
|
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_MAC,CFG_RAW_INT_ENA_ADDR, reg_intr_en);
|
||
|
g_rawdata.subfunc_exe_flag |= 0x8;
|
||
|
}
|
||
|
|
||
|
g_rawdata.subfunc_exe_flag |= 0x10;
|
||
|
/* handle phy intr */
|
||
|
if(irq_type & (INTR_TYPE_PHY_RECV_FC|INTR_TYPE_PHY_RECV_FC_TIMOUT|INTR_TYPE_PHY_TX_FC_TIMEOUT)){
|
||
|
|
||
|
g_rawdata.subfunc_exe_flag |= 0x20;
|
||
|
if(irq_type & INTR_TYPE_PHY_RECV_FC){
|
||
|
g_rawdata.subfunc_exe_flag |= 0x40;
|
||
|
reg_int = iot_raw_read_reg(RAW_REG_TYPE_PHY, CFG_BB_INT_EN_1_ADDR);
|
||
|
reg_int &= (~PHY_RECV_FC_MASK);
|
||
|
g_rawdata.subfunc_exe_flag |= 0x80;
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_PHY,CFG_BB_INT_EN_1_ADDR, reg_int);
|
||
|
g_rawdata.subfunc_exe_flag |= 0x100;
|
||
|
}
|
||
|
g_rawdata.subfunc_exe_flag |= 0x200;
|
||
|
if(irq_type & INTR_TYPE_PHY_RECV_FC_TIMOUT){
|
||
|
g_rawdata.subfunc_exe_flag |= 0x400;
|
||
|
reg_int = iot_raw_read_reg(RAW_REG_TYPE_PHY,CFG_BB_INT_EN_2_ADDR);
|
||
|
reg_int &=(~PHY_RECV_FC_TIMEOUT);
|
||
|
g_rawdata.subfunc_exe_flag |= 0x800;
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_PHY,CFG_BB_INT_EN_2_ADDR, reg_int);
|
||
|
g_rawdata.subfunc_exe_flag |= 0x1000;
|
||
|
}
|
||
|
|
||
|
g_rawdata.subfunc_exe_flag |= 0x2000;
|
||
|
if(irq_type & INTR_TYPE_PHY_TX_FC_TIMEOUT){
|
||
|
g_rawdata.subfunc_exe_flag |= 0x4000;
|
||
|
reg_int = iot_raw_read_reg(RAW_REG_TYPE_PHY,CFG_BB_INT_EN_3_ADDR);
|
||
|
g_rawdata.subfunc_exe_flag |= 0x8000;
|
||
|
reg_int &= (~PHY_RECV_TX_FC_TIMEOUT);
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_PHY,CFG_BB_INT_EN_3_ADDR, reg_int);
|
||
|
g_rawdata.subfunc_exe_flag |= 0x10000;
|
||
|
}
|
||
|
}
|
||
|
g_rawdata.subfunc_exe_flag |= 0x20000;
|
||
|
/*only boot up set irq_type = INTR_TYPE_RAW_ALL*/
|
||
|
if(irq_type != INTR_TYPE_RAW_ALL){
|
||
|
|
||
|
if(irq_type & INTR_TYPE_MAC_TX_FC){
|
||
|
pmsg = &g_rawdata.tx_msg[g_rawdata.txmsg_idx];
|
||
|
}else if(irq_type & INTR_TYPE_MAC_TX_SACK_FC){
|
||
|
pmsg = &g_rawdata.ack_msg[g_rawdata.ackmsg_idx];
|
||
|
}else if(irq_type & INTR_TYPE_PHY_RECV_FC){
|
||
|
pmsg = &g_rawdata.rec_msg[g_rawdata.recmsg_idx];
|
||
|
}
|
||
|
|
||
|
#ifdef RAWDATA_TIME_PROFILE_ENABLE
|
||
|
g_rawdata.subfunc_exe_flag |= 0x40000;
|
||
|
/* log interrupt trigger time */
|
||
|
if(pmsg){
|
||
|
g_rawdata.subfunc_exe_flag |= 0x80000;
|
||
|
iot_rawdata_mark_timestamp(&pmsg->profile.rawdata_interrupt_trigger_ticks);
|
||
|
}
|
||
|
#endif
|
||
|
}
|
||
|
g_rawdata.subfunc_exe_flag |= 0x100000;
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
void iot_enable_hw_interrupt(uint32_t irq_type)
|
||
|
{
|
||
|
uint32_t reg_intr_en = 0;
|
||
|
uint32_t reg_int = 0;
|
||
|
fc_trans_msg* pmsg = NULL;
|
||
|
#ifdef ENABLE_PRINT
|
||
|
iot_printf("iot_enable_hw_interrupt:%x\n", irq_type);
|
||
|
#endif
|
||
|
/* handle mac intr */
|
||
|
if(irq_type & (INTR_TYPE_MAC_TX_FC|INTR_TYPE_MAC_TX_SACK_FC)){
|
||
|
|
||
|
/* set mac isr mapping to cpu irq# */
|
||
|
if(irq_type & INTR_TYPE_MAC_TX_FC){
|
||
|
reg_int = iot_raw_read_reg(RAW_REG_TYPE_MAC,CFG_RAW_INT_PRI2_MASK_ADDR);
|
||
|
reg_int |= MAC_TX_FC_MASK;
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_MAC,CFG_RAW_INT_PRI2_MASK_ADDR, reg_int);
|
||
|
}
|
||
|
|
||
|
if(irq_type & INTR_TYPE_MAC_TX_SACK_FC){
|
||
|
reg_int = iot_raw_read_reg(RAW_REG_TYPE_MAC,CFG_RAW_INT_PRI3_MASK_ADDR);
|
||
|
reg_int |= MAC_TX_SACK_FC_MASK;
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_MAC,CFG_RAW_INT_PRI3_MASK_ADDR, reg_int);
|
||
|
}
|
||
|
|
||
|
|
||
|
reg_intr_en = iot_raw_read_reg(RAW_REG_TYPE_MAC,CFG_RAW_INT_ENA_ADDR);
|
||
|
|
||
|
if(irq_type & INTR_TYPE_MAC_TX_FC){
|
||
|
reg_intr_en |= MAC_TX_FC_MASK;
|
||
|
}
|
||
|
|
||
|
if(irq_type & INTR_TYPE_MAC_TX_SACK_FC){
|
||
|
reg_intr_en |= MAC_TX_SACK_FC_MASK;
|
||
|
}
|
||
|
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_MAC,CFG_RAW_INT_ENA_ADDR, reg_intr_en);
|
||
|
|
||
|
}
|
||
|
|
||
|
/* handle phy intr */
|
||
|
if(irq_type & (INTR_TYPE_PHY_RECV_FC|INTR_TYPE_PHY_RECV_FC_TIMOUT|INTR_TYPE_PHY_TX_FC_TIMEOUT)){
|
||
|
if(irq_type & INTR_TYPE_PHY_RECV_FC){
|
||
|
reg_int = iot_raw_read_reg(RAW_REG_TYPE_PHY, CFG_BB_INT_EN_1_ADDR);
|
||
|
reg_int |= PHY_RECV_FC_MASK;
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_PHY, CFG_BB_INT_EN_1_ADDR, reg_int);
|
||
|
}
|
||
|
|
||
|
if(irq_type & INTR_TYPE_PHY_RECV_FC_TIMOUT){
|
||
|
reg_int = iot_raw_read_reg(RAW_REG_TYPE_PHY,CFG_BB_INT_EN_2_ADDR);
|
||
|
reg_int |= PHY_RECV_FC_TIMEOUT;
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_PHY,CFG_BB_INT_EN_2_ADDR, reg_int);
|
||
|
}
|
||
|
|
||
|
if(irq_type & INTR_TYPE_PHY_TX_FC_TIMEOUT){
|
||
|
reg_int = iot_raw_read_reg(RAW_REG_TYPE_PHY,CFG_BB_INT_EN_3_ADDR);
|
||
|
reg_int |= PHY_RECV_TX_FC_TIMEOUT;
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_PHY,CFG_BB_INT_EN_3_ADDR, reg_int);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
/*only boot up set irq_type = INTR_TYPE_RAW_ALL*/
|
||
|
if(irq_type != INTR_TYPE_RAW_ALL){
|
||
|
if(irq_type & INTR_TYPE_MAC_TX_FC){
|
||
|
pmsg = &g_rawdata.tx_msg[g_rawdata.txmsg_idx];
|
||
|
}else if(irq_type & INTR_TYPE_MAC_TX_SACK_FC){
|
||
|
pmsg = &g_rawdata.ack_msg[g_rawdata.ackmsg_idx];
|
||
|
}else if(irq_type & INTR_TYPE_PHY_RECV_FC){
|
||
|
pmsg = &g_rawdata.rec_msg[g_rawdata.recmsg_idx];
|
||
|
}
|
||
|
|
||
|
#ifdef RAWDATA_TIME_PROFILE_ENABLE
|
||
|
/* log interrupt trigger time */
|
||
|
if(pmsg){
|
||
|
iot_rawdata_mark_timestamp(&pmsg->profile.rawdata_interrupt_release_ticks);
|
||
|
}
|
||
|
#endif
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
|
||
|
uint32_t iot_get_hw_interrupt_type(void)
|
||
|
{
|
||
|
uint32_t irq_type_reg = 0;
|
||
|
uint32_t irq_type = 0;
|
||
|
|
||
|
/* handle mac irq */
|
||
|
irq_type_reg = iot_raw_read_reg(RAW_REG_TYPE_MAC, CFG_RAW_INT_STATUS_ADDR);
|
||
|
irq_type_reg &= RO_RAW_INT_STATUS_MASK;
|
||
|
|
||
|
if(irq_type_reg & MAC_TX_FC_MASK){
|
||
|
irq_type |= INTR_TYPE_MAC_TX_FC;
|
||
|
}
|
||
|
|
||
|
if(irq_type_reg & MAC_TX_SACK_FC_MASK){
|
||
|
irq_type |= INTR_TYPE_MAC_TX_SACK_FC;
|
||
|
}
|
||
|
|
||
|
|
||
|
/* handle phy status */
|
||
|
irq_type_reg = iot_raw_read_reg(RAW_REG_TYPE_PHY, CFG_BB_INT_MASK_1_ADDR);
|
||
|
if(irq_type_reg & PHY_RECV_FC_MASK){
|
||
|
irq_type |= INTR_TYPE_PHY_RECV_FC;
|
||
|
}
|
||
|
|
||
|
irq_type_reg = iot_raw_read_reg(RAW_REG_TYPE_PHY, CFG_BB_INT_MASK_2_ADDR);
|
||
|
if(irq_type_reg & PHY_RECV_FC_TIMEOUT){
|
||
|
irq_type |= INTR_TYPE_PHY_RECV_FC_TIMOUT;
|
||
|
}
|
||
|
|
||
|
irq_type_reg = iot_raw_read_reg(RAW_REG_TYPE_PHY,CFG_BB_INT_MASK_3_ADDR);
|
||
|
if(irq_type_reg & PHY_RECV_TX_FC_TIMEOUT){
|
||
|
irq_type |= INTR_TYPE_PHY_TX_FC_TIMEOUT;
|
||
|
}
|
||
|
|
||
|
return irq_type;
|
||
|
}
|
||
|
|
||
|
|
||
|
uint32_t iot_rawdata_set_translate_sack_fc(fc_trans_msg* rawfc)
|
||
|
{
|
||
|
uint32_t idx = 0;
|
||
|
#ifdef ENABLE_PRINT
|
||
|
iot_printf("set_mac_sack_fc\n");
|
||
|
#endif
|
||
|
/* caculate crc data here */
|
||
|
iot_rawdata_set_crc(rawfc);
|
||
|
|
||
|
/* Set Data */
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_MAC,CFG_TX_SW_FC_0_ADDR,rawfc->trans_fc[idx++]);
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_MAC,CFG_TX_SW_FC_1_ADDR,rawfc->trans_fc[idx++]);
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_MAC,CFG_TX_SW_FC_2_ADDR,rawfc->trans_fc[idx++]);
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_MAC,CFG_TX_SW_FC_3_ADDR,rawfc->trans_fc[idx++]);
|
||
|
|
||
|
/* Valid data */
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_MAC ,CFG_SW_FC_VALID_ADDR, 1);
|
||
|
|
||
|
#ifdef RAWDATA_TIME_PROFILE_ENABLE
|
||
|
/* log interrupt trigger time */
|
||
|
iot_rawdata_mark_timestamp(&rawfc->profile.rawdata_set_translate_fc_ticks);
|
||
|
#endif
|
||
|
|
||
|
return ERR_OK;
|
||
|
}
|
||
|
|
||
|
|
||
|
uint32_t iot_rawdata_translate_hwsack_fc(fc_trans_msg *rawfc, \
|
||
|
uint32_t src_prot, uint32_t trans_prot)
|
||
|
{
|
||
|
/*
|
||
|
* consider two cases. 1. src_prot and trans_prot are same, but minor
|
||
|
* version different. 2. src_prot and trans_prot are different.
|
||
|
* 2nd case should not to hit, focus on case 1 currently.
|
||
|
*/
|
||
|
frame_control_t* src_sgfc = NULL;
|
||
|
frame_control_t* trans_sgfc = NULL;
|
||
|
|
||
|
spg_frame_control_t* src_spgfc = NULL;
|
||
|
spg_frame_control_t* trans_spgfc = NULL;
|
||
|
|
||
|
if(src_prot == trans_prot){
|
||
|
if(src_prot == PLC_PROTO_TYPE_SG){
|
||
|
src_sgfc = (frame_control_t*)rawfc->org_fc;
|
||
|
trans_sgfc = (frame_control_t*)rawfc->trans_fc;
|
||
|
|
||
|
/* real work should be bits adjustment in same prot family
|
||
|
* currently just copy
|
||
|
*/
|
||
|
os_mem_cpy(trans_sgfc,src_sgfc,(RAW_FC_LEN_DW*sizeof(uint32_t)) );
|
||
|
|
||
|
//trans_sgfc->vf.sof.pb_num = 1;
|
||
|
|
||
|
}else if (src_prot == PLC_PROTO_TYPE_SPG){
|
||
|
src_spgfc = (spg_frame_control_t*)rawfc->org_fc;
|
||
|
trans_spgfc =(spg_frame_control_t*)rawfc->trans_fc;
|
||
|
|
||
|
/* real work should be bits adjustment in same prot family
|
||
|
* currently just copy
|
||
|
*/
|
||
|
os_mem_cpy(trans_spgfc, src_spgfc,(RAW_FC_LEN_DW*sizeof(uint32_t)));
|
||
|
}else{
|
||
|
IOT_ASSERT(0);
|
||
|
}
|
||
|
|
||
|
}else{
|
||
|
IOT_ASSERT(0);
|
||
|
#if 0
|
||
|
if(src_prot == PLC_PROTO_TYPE_SG){
|
||
|
src_sgfc = rawfc->org_fc;
|
||
|
trans_spgfc = rawfc->trans_fc;
|
||
|
|
||
|
}else if {src_prot == PLC_PROTO_TYPE_SPG){
|
||
|
src_spgfc = rawfc->org_fc;
|
||
|
trans_sgfc = rawfc->trans_fc;
|
||
|
|
||
|
/* spg -> sg */
|
||
|
|
||
|
}else{
|
||
|
IOT_ASSERT(0);
|
||
|
}
|
||
|
#endif
|
||
|
}
|
||
|
|
||
|
#ifdef RAWDATA_TIME_PROFILE_ENABLE
|
||
|
/* log interrupt trigger time */
|
||
|
iot_rawdata_mark_timestamp(&rawfc->profile.rawdata_translate_fc_ticks);
|
||
|
#endif
|
||
|
|
||
|
return ERR_OK;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
uint32_t iot_rawdata_get_hw_sack_fc_bytes(fc_trans_msg *rawfc)
|
||
|
{
|
||
|
|
||
|
uint32_t idx=0;
|
||
|
#ifdef ENABLE_PRINT
|
||
|
iot_printf("get_mac_sack_fc\n");
|
||
|
#endif
|
||
|
/* Per bairu, hw tx sack fc hw reg same as CPU0 send fc addr */
|
||
|
rawfc->org_fc[idx++]= iot_raw_read_reg(RAW_REG_TYPE_MAC, CFG_TX_RAW_FC_0_ADDR);
|
||
|
rawfc->org_fc[idx++]= iot_raw_read_reg(RAW_REG_TYPE_MAC, CFG_TX_RAW_FC_1_ADDR);
|
||
|
rawfc->org_fc[idx++]= iot_raw_read_reg(RAW_REG_TYPE_MAC, CFG_TX_RAW_FC_2_ADDR);
|
||
|
rawfc->org_fc[idx++]= iot_raw_read_reg(RAW_REG_TYPE_MAC, CFG_TX_RAW_FC_3_ADDR);
|
||
|
|
||
|
#ifdef RAWDATA_TIME_PROFILE_ENABLE
|
||
|
/* log interrupt trigger time */
|
||
|
iot_rawdata_mark_timestamp(&rawfc->profile.rawdata_get_fc_ticks);
|
||
|
#endif
|
||
|
|
||
|
return ERR_OK;
|
||
|
}
|
||
|
|
||
|
volatile uint32_t changeid = 1;
|
||
|
uint32_t iot_rawdata_modify_tx_fc(fc_trans_msg *rawfc)
|
||
|
{
|
||
|
uint32_t idx = 0;
|
||
|
#ifdef ENABLE_PRINT
|
||
|
iot_printf("modify_tx_fc\n");
|
||
|
#endif
|
||
|
|
||
|
|
||
|
/* Set TX_FC_DATA0~4 and TX_FC_NEED_UPD to change fc content */
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_MAC, CFG_TX_FC_DATA0_ADDR, rawfc->org_fc [idx++]);
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_MAC, CFG_TX_FC_DATA1_ADDR, rawfc->org_fc[idx++]);
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_MAC, CFG_TX_FC_DATA2_ADDR, rawfc->org_fc[idx++]);
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_MAC, CFG_TX_FC_DATA3_ADDR, rawfc->org_fc[idx++]);
|
||
|
|
||
|
g_rawdata.dbgchangeid = changeid;
|
||
|
/*Place to change modified FC */
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_MAC, CFG_TX_FC_DATA0_ADDR, (rawfc->org_fc[0]+(changeid<<24)));
|
||
|
changeid++;
|
||
|
if(changeid>0x9){
|
||
|
changeid = 0;
|
||
|
}
|
||
|
|
||
|
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_MAC, CFG_TX_FC_NEED_UPD_ADDR,1);
|
||
|
|
||
|
return ERR_OK;
|
||
|
}
|
||
|
|
||
|
|
||
|
uint32_t iot_rawdata_set_translate_tx_fc(fc_trans_msg *rawfc)
|
||
|
{
|
||
|
uint32_t idx = 0;
|
||
|
#ifdef ENABLE_PRINT
|
||
|
iot_printf("set_mac_tx_fc\n");
|
||
|
#endif
|
||
|
/* caculate crc data here */
|
||
|
iot_rawdata_set_crc(rawfc);
|
||
|
|
||
|
/* Set Data */
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_MAC,CFG_TX_SW_FC_0_ADDR,rawfc->trans_fc[idx++]);
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_MAC,CFG_TX_SW_FC_1_ADDR,rawfc->trans_fc[idx++]);
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_MAC,CFG_TX_SW_FC_2_ADDR,rawfc->trans_fc[idx++]);
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_MAC,CFG_TX_SW_FC_3_ADDR,rawfc->trans_fc[idx++]);
|
||
|
|
||
|
//iot_rawdata_modify_tx_fc(rawfc);
|
||
|
|
||
|
/* Valid data */
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_MAC,CFG_SW_FC_VALID_ADDR, 1);
|
||
|
|
||
|
#ifdef RAWDATA_TIME_PROFILE_ENABLE
|
||
|
/* log interrupt trigger time */
|
||
|
iot_rawdata_mark_timestamp(&rawfc->profile.rawdata_set_translate_fc_ticks);
|
||
|
#endif
|
||
|
|
||
|
return ERR_OK;
|
||
|
}
|
||
|
|
||
|
|
||
|
uint32_t iot_rawdata_translate_tx_fc(fc_trans_msg *rawfc, \
|
||
|
uint32_t src_prot, uint32_t trans_prot)
|
||
|
{
|
||
|
/*
|
||
|
* consider two cases. 1. src_prot and trans_prot are same, but minor
|
||
|
* version different. 2. src_prot and trans_prot are different.
|
||
|
* 2nd case should not to hit, focus on case 1 currently.
|
||
|
*/
|
||
|
frame_control_t* src_sgfc = NULL;
|
||
|
frame_control_t* trans_sgfc = NULL;
|
||
|
|
||
|
spg_frame_control_t* src_spgfc = NULL;
|
||
|
spg_frame_control_t* trans_spgfc = NULL;
|
||
|
|
||
|
if(src_prot == trans_prot){
|
||
|
if(src_prot == PLC_PROTO_TYPE_SG){
|
||
|
src_sgfc = (frame_control_t*)rawfc->org_fc;
|
||
|
trans_sgfc = (frame_control_t*)rawfc->trans_fc;
|
||
|
|
||
|
/* real work should be bits adjustment in same prot family
|
||
|
* currently just copy
|
||
|
*/
|
||
|
os_mem_cpy(trans_sgfc,src_sgfc,(RAW_FC_LEN_DW*sizeof(uint32_t)) );
|
||
|
|
||
|
|
||
|
trans_sgfc->vf.sof.pb_num = 1;
|
||
|
|
||
|
#if 0
|
||
|
/* hack tei for tesint */
|
||
|
switch(trans_sgfc->delimiter_type){
|
||
|
case FC_DELIM_SOF:
|
||
|
trans_sgfc->vf.sof.src_tei+= 1;
|
||
|
break;
|
||
|
case FC_DELIM_BEACON:
|
||
|
break;
|
||
|
case FC_DELIM_NNCCO:
|
||
|
break;
|
||
|
case FC_DELIM_SOUND:
|
||
|
break;
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
}else if (src_prot == PLC_PROTO_TYPE_SPG){
|
||
|
src_spgfc = (spg_frame_control_t*)rawfc->org_fc;
|
||
|
trans_spgfc = (spg_frame_control_t*)rawfc->trans_fc;
|
||
|
|
||
|
/* real work should be bits adjustment in same prot family
|
||
|
* currently just copy
|
||
|
*/
|
||
|
os_mem_cpy(trans_spgfc, src_spgfc,(RAW_FC_LEN_DW*sizeof(uint32_t)));
|
||
|
}else{
|
||
|
IOT_ASSERT(0);
|
||
|
}
|
||
|
|
||
|
}else{
|
||
|
IOT_ASSERT(0);
|
||
|
#if 0
|
||
|
if(src_prot == PLC_PROTO_TYPE_SG){
|
||
|
src_sgfc = rawfc->org_fc;
|
||
|
trans_spgfc = rawfc->trans_fc;
|
||
|
|
||
|
}else if {src_prot == PLC_PROTO_TYPE_SPG){
|
||
|
src_spgfc = rawfc->org_fc;
|
||
|
trans_sgfc = rawfc->trans_fc;
|
||
|
|
||
|
/* spg -> sg */
|
||
|
|
||
|
}else{
|
||
|
IOT_ASSERT(0);
|
||
|
}
|
||
|
#endif
|
||
|
}
|
||
|
#ifdef RAWDATA_TIME_PROFILE_ENABLE
|
||
|
/* log interrupt trigger time */
|
||
|
iot_rawdata_mark_timestamp(&rawfc->profile.rawdata_translate_fc_ticks);
|
||
|
#endif
|
||
|
|
||
|
return ERR_OK;
|
||
|
}
|
||
|
|
||
|
|
||
|
uint32_t iot_rawdata_get_tx_fc_bytes(fc_trans_msg *rawfc)
|
||
|
{
|
||
|
uint32_t idx=0;
|
||
|
#ifdef ENABLE_PRINT
|
||
|
iot_printf("get_mac_tx_fc\n");
|
||
|
#endif
|
||
|
rawfc->org_fc[idx++]= iot_raw_read_reg(RAW_REG_TYPE_MAC,CFG_TX_RAW_FC_0_ADDR);
|
||
|
rawfc->org_fc[idx++]= iot_raw_read_reg(RAW_REG_TYPE_MAC,CFG_TX_RAW_FC_1_ADDR);
|
||
|
rawfc->org_fc[idx++]= iot_raw_read_reg(RAW_REG_TYPE_MAC,CFG_TX_RAW_FC_2_ADDR);
|
||
|
rawfc->org_fc[idx++]= iot_raw_read_reg(RAW_REG_TYPE_MAC,CFG_TX_RAW_FC_3_ADDR);
|
||
|
|
||
|
#ifdef RAWDATA_TIME_PROFILE_ENABLE
|
||
|
/* log interrupt trigger time */
|
||
|
iot_rawdata_mark_timestamp(&rawfc->profile.rawdata_get_fc_ticks);
|
||
|
#endif
|
||
|
|
||
|
return ERR_OK;
|
||
|
}
|
||
|
|
||
|
|
||
|
uint32_t iot_rawdata_get_hw_receive_fc_bytes(fc_trans_msg *rawfc)
|
||
|
{
|
||
|
uint32_t ret = ERR_OK;
|
||
|
uint32_t idx = 0;
|
||
|
#ifdef ENABLE_PRINT
|
||
|
iot_printf("get_phy_rec_fc\n");
|
||
|
#endif
|
||
|
rawfc->org_fc[idx++]= iot_raw_read_reg(RAW_REG_TYPE_PHY,CFG_BB_RX_FC_RAW_0_ADDR);
|
||
|
rawfc->org_fc[idx++]= iot_raw_read_reg(RAW_REG_TYPE_PHY,CFG_BB_RX_FC_RAW_1_ADDR);
|
||
|
rawfc->org_fc[idx++]= iot_raw_read_reg(RAW_REG_TYPE_PHY,CFG_BB_RX_FC_RAW_2_ADDR);
|
||
|
rawfc->org_fc[idx++]= iot_raw_read_reg(RAW_REG_TYPE_PHY,CFG_BB_RX_FC_RAW_3_ADDR);
|
||
|
|
||
|
#ifdef RAWDATA_TIME_PROFILE_ENABLE
|
||
|
/* log interrupt trigger time */
|
||
|
iot_rawdata_mark_timestamp(&rawfc->profile.rawdata_get_fc_ticks);
|
||
|
#endif
|
||
|
|
||
|
ret = iot_rawdata_valid_crc(rawfc);
|
||
|
return ret;
|
||
|
}
|
||
|
|
||
|
uint32_t iot_rawdata_translate_hwrec_fc(fc_trans_msg *rawfc, \
|
||
|
uint32_t src_prot, uint32_t trans_prot)
|
||
|
{
|
||
|
/*
|
||
|
* consider two cases. 1. src_prot and trans_prot are same, but minor
|
||
|
* version different. 2. src_prot and trans_prot are different.
|
||
|
* 2nd case should not to hit, focus on case 1 currently.
|
||
|
*/
|
||
|
frame_control_t* src_sgfc = NULL;
|
||
|
frame_control_t* trans_sgfc = NULL;
|
||
|
|
||
|
spg_frame_control_t* src_spgfc = NULL;
|
||
|
spg_frame_control_t* trans_spgfc = NULL;
|
||
|
|
||
|
if(src_prot == trans_prot){
|
||
|
if(src_prot == PLC_PROTO_TYPE_SG){
|
||
|
src_sgfc = (frame_control_t*)rawfc->org_fc;
|
||
|
trans_sgfc = (frame_control_t*)rawfc->trans_fc;
|
||
|
|
||
|
/* real work should be bits adjustment in same prot family
|
||
|
* currently just copy
|
||
|
*/
|
||
|
os_mem_cpy(trans_sgfc,src_sgfc,(RAW_FC_LEN_DW*sizeof(uint32_t)) );
|
||
|
/*
|
||
|
sender is 0x51000cfc is old sg
|
||
|
current is 0x51000cfc is 630 sg,
|
||
|
now convert to old sg
|
||
|
*/
|
||
|
|
||
|
|
||
|
trans_sgfc->vf.sof.pb_num = 1;
|
||
|
|
||
|
|
||
|
}else if (src_prot == PLC_PROTO_TYPE_SPG){
|
||
|
src_spgfc = (spg_frame_control_t*)rawfc->org_fc;
|
||
|
trans_spgfc =(spg_frame_control_t*)rawfc->trans_fc;
|
||
|
|
||
|
/* real work should be bits adjustment in same prot family
|
||
|
* currently just copy
|
||
|
*/
|
||
|
os_mem_cpy(trans_spgfc, src_spgfc,(RAW_FC_LEN_DW*sizeof(uint32_t)));
|
||
|
}else{
|
||
|
IOT_ASSERT(0);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
#ifdef RAWDATA_TIME_PROFILE_ENABLE
|
||
|
/* log interrupt trigger time */
|
||
|
iot_rawdata_mark_timestamp(&rawfc->profile.rawdata_translate_fc_ticks);
|
||
|
#endif
|
||
|
|
||
|
return ERR_OK;
|
||
|
}
|
||
|
|
||
|
uint32_t iot_rawdata_set_translate_recv_fc(fc_trans_msg *rawfc)
|
||
|
{
|
||
|
uint32_t idx = 0;
|
||
|
uint32_t word3 = 0;
|
||
|
#ifdef ENABLE_PRINT
|
||
|
iot_printf("set_phy_fc\n");
|
||
|
#endif
|
||
|
/* caculate crc data here */
|
||
|
iot_rawdata_set_crc(rawfc);
|
||
|
|
||
|
/* Set Data */
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_PHY,CFG_BB_RX_FC_CFG_0_ADDR,rawfc->trans_fc[idx++]);
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_PHY,CFG_BB_RX_FC_CFG_1_ADDR,rawfc->trans_fc[idx++]);
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_PHY,CFG_BB_RX_FC_CFG_2_ADDR,rawfc->trans_fc[idx++]);
|
||
|
|
||
|
/* word3 flag+valid bit*/
|
||
|
#if 0
|
||
|
/* err case */
|
||
|
word3 = (rawfc->trans_fc[idx++] & 0xFF)|SW_RX_FC_NOW_CFG_VLD_OFFSET;
|
||
|
#endif
|
||
|
|
||
|
word3 = (rawfc->trans_fc[idx++] & 0xFF)|(1<<SW_RX_FC_NOW_CFG_VLD_OFFSET);
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_PHY,CFG_BB_RX_FC_CFG_3_ADDR,word3);
|
||
|
|
||
|
|
||
|
#ifdef RAWDATA_TIME_PROFILE_ENABLE
|
||
|
/* log interrupt trigger time */
|
||
|
iot_rawdata_mark_timestamp(&rawfc->profile.rawdata_set_translate_fc_ticks);
|
||
|
#endif
|
||
|
|
||
|
return ERR_OK;
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
#define RAW_BB_VERSION_NEW_SG 0
|
||
|
#define RAW_BB_VERSION_GP 1
|
||
|
#define RAW_BB_VERSION_MIX 2
|
||
|
#define RAW_BB_VERSION_OLD_SG 3
|
||
|
*/
|
||
|
|
||
|
uint32_t iot_rawdata_hw_set(uint32_t on, uint32_t src_prot,\
|
||
|
uint32_t trans_prot)
|
||
|
{
|
||
|
iot_printf("iot_rawdata_hw_set on:%x src_prot:%x trans_prot:%x\n", on, src_prot, trans_prot);
|
||
|
/* set mac raw mode */
|
||
|
src_prot &= CFG_SW_TX_PROTO_MASK;
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_MAC,CFG_SW_TX_PROTO_ADDR, src_prot);
|
||
|
|
||
|
/* set rx raw mode */
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_MAC,CFG_RAW_DATA_MODE_ADDR, 1);
|
||
|
|
||
|
/* set bb raw mode */
|
||
|
//PHY_WRITE_REG(CFG_BB_RTL_VERSION_ADDR, RAW_BB_VERSION_NEW_SG);
|
||
|
|
||
|
/* set bb */
|
||
|
iot_raw_write_reg(RAW_REG_TYPE_PHY,CFG_BB_RAW_DATA_MODE_CTRL_ADDR, 1);
|
||
|
|
||
|
|
||
|
return ERR_OK;
|
||
|
}
|
||
|
|
||
|
|
||
|
uint32_t iot_rawdata_context_init(rawdata_context* cxt)
|
||
|
{
|
||
|
iot_printf("iot_rawdata_context_init\n");
|
||
|
/* zero memory */
|
||
|
os_mem_set((void*)cxt, 0, sizeof(rawdata_context));
|
||
|
|
||
|
|
||
|
/* set src_prot and trans_prot */
|
||
|
cxt->src_prot = PLC_PROTO_TYPE_SG;
|
||
|
cxt->trans_prot = PLC_PROTO_TYPE_SG;
|
||
|
|
||
|
g_rawdata.dbgchangeid = 2;
|
||
|
g_rawdata.irq_time = 0;
|
||
|
return ERR_OK;
|
||
|
}
|
||
|
|
||
|
volatile uint32_t int_loop = 0;
|
||
|
volatile uint32_t timeout_tx = 0;
|
||
|
volatile uint32_t timeout_rx= 0;
|
||
|
uint32_t iot_rawdata_interrupt_handler(uint32_t vector, iot_addrword_t data)
|
||
|
{
|
||
|
uint32_t isr_flag = 0;
|
||
|
fc_trans_msg *p_msg = NULL;
|
||
|
uint32_t src_prot = 0;
|
||
|
uint32_t trans_prot = 0;
|
||
|
//uint32_t reg_rx_sgver = 0;
|
||
|
|
||
|
g_rawdata.exc_flag = 0x0;
|
||
|
int_loop++;
|
||
|
g_rawdata.irq_time = int_loop;
|
||
|
g_rawdata.timeout_rxcnt = timeout_rx;
|
||
|
g_rawdata.timeout_txcnt = timeout_tx;
|
||
|
g_rawdata.pre_irq_catch = g_rawdata.irq_catch;
|
||
|
g_rawdata.irq_catch = 0;
|
||
|
|
||
|
g_rawdata.pre_exc_flag = g_rawdata.exc_flag;
|
||
|
g_rawdata.exc_flag = 0x1;
|
||
|
#ifdef ENABLE_PRINT
|
||
|
iot_printf("Interrupt Handler %d\n", int_loop);
|
||
|
#endif
|
||
|
|
||
|
#if 0
|
||
|
reg_rx_sgver = (*(volatile uint32_t*)0x51000cfc);
|
||
|
reg_rx_sgver |= 0x2;
|
||
|
(*(volatile uint32_t*)0x51000cfc) = reg_rx_sgver;
|
||
|
//iot_printf("hardcode sg ver:0x%x", (*(uint32_t*)0x51000cfc));
|
||
|
#endif
|
||
|
|
||
|
trans_prot = trans_prot;
|
||
|
src_prot = src_prot;
|
||
|
p_msg = p_msg;
|
||
|
|
||
|
vector = vector;
|
||
|
data = data;
|
||
|
|
||
|
src_prot = g_rawdata.src_prot;
|
||
|
trans_prot = g_rawdata.trans_prot;
|
||
|
|
||
|
g_rawdata.exc_flag |= 0x2;
|
||
|
isr_flag = iot_get_hw_interrupt_type();
|
||
|
g_rawdata.exc_flag |= 0x4;
|
||
|
|
||
|
g_rawdata.irq_catch = isr_flag;
|
||
|
|
||
|
#ifdef ENABLE_PRINT
|
||
|
iot_printf("-------raw_data interrupt:0x%x\n", isr_flag);
|
||
|
#endif
|
||
|
|
||
|
/* disable interrupt mask */
|
||
|
iot_disable_hw_interrupt(isr_flag);
|
||
|
|
||
|
g_rawdata.exc_flag |= 0x8;
|
||
|
/* disable soc interrupt */
|
||
|
//iot_rawdata_soc_disable_all_isr();
|
||
|
|
||
|
|
||
|
|
||
|
/* get interrupt type, so, we know which path should go */
|
||
|
#ifdef RUN_MODE_IN_INTERRUPT
|
||
|
if(isr_flag & INTR_TYPE_TIMEOUT_ERR){
|
||
|
if(isr_flag & INTR_TYPE_PHY_RECV_FC_TIMOUT){
|
||
|
timeout_rx++;
|
||
|
}else{
|
||
|
timeout_tx++;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
/* call do work function here */
|
||
|
if(isr_flag & INTR_TYPE_MAC_TX_FC){
|
||
|
|
||
|
g_rawdata.exc_flag |= 0x10;
|
||
|
/* call do work function here */
|
||
|
p_msg = &g_rawdata.tx_msg[g_rawdata.txmsg_idx];
|
||
|
iot_rawdata_get_tx_fc_bytes(p_msg);
|
||
|
|
||
|
g_rawdata.exc_flag |= 0x20;
|
||
|
iot_rawdata_translate_tx_fc(p_msg, src_prot, trans_prot);
|
||
|
|
||
|
if(isr_flag & INTR_TYPE_TIMEOUT_ERR){
|
||
|
iot_printf("TX FC HIT TIMEOUT:%x index:%d\n", isr_flag, g_rawdata.txmsg_idx);
|
||
|
p_msg->profile.rawdata_set_translate_fc_ticks = 0xFFFFFFFF;
|
||
|
}else{
|
||
|
iot_rawdata_set_translate_tx_fc(p_msg);
|
||
|
}
|
||
|
p_msg->profile.irq_type = isr_flag;
|
||
|
g_rawdata.exc_flag |= 0x40;
|
||
|
}
|
||
|
|
||
|
if(isr_flag & INTR_TYPE_MAC_TX_SACK_FC){
|
||
|
|
||
|
g_rawdata.exc_flag |= 0x80;
|
||
|
/* call do work function here */
|
||
|
p_msg = &g_rawdata.ack_msg[g_rawdata.ackmsg_idx];
|
||
|
|
||
|
iot_rawdata_get_hw_sack_fc_bytes(p_msg);
|
||
|
|
||
|
g_rawdata.exc_flag |= 0x100;
|
||
|
|
||
|
iot_rawdata_translate_hwsack_fc(p_msg, src_prot, trans_prot);
|
||
|
|
||
|
g_rawdata.exc_flag |= 0x200;
|
||
|
if(isr_flag & INTR_TYPE_TIMEOUT_ERR){
|
||
|
iot_printf("TX SACK FC HIT TIMEOUT:%x index:%d\n", isr_flag,g_rawdata.ackmsg_idx );
|
||
|
p_msg->profile.rawdata_set_translate_fc_ticks = 0xFFFFFFFF;
|
||
|
}else{
|
||
|
iot_rawdata_set_translate_sack_fc(p_msg);
|
||
|
}
|
||
|
p_msg->profile.irq_type = isr_flag;
|
||
|
g_rawdata.exc_flag |= 0x400;
|
||
|
}
|
||
|
|
||
|
if(isr_flag & INTR_TYPE_PHY_RECV_FC){
|
||
|
|
||
|
g_rawdata.exc_flag |= 0x800;
|
||
|
/* HW Received FC */
|
||
|
p_msg = &g_rawdata.rec_msg[g_rawdata.recmsg_idx];
|
||
|
|
||
|
if(iot_rawdata_get_hw_receive_fc_bytes(p_msg) == ERR_OK){
|
||
|
|
||
|
g_rawdata.exc_flag |= 0x1000;
|
||
|
iot_rawdata_translate_hwrec_fc(p_msg, src_prot, trans_prot);
|
||
|
if(isr_flag & INTR_TYPE_TIMEOUT_ERR){
|
||
|
iot_printf("RX FC HIT TIMEOUT:%x index:%d\n", isr_flag,g_rawdata.recmsg_idx);
|
||
|
p_msg->profile.rawdata_set_translate_fc_ticks = 0xFFFFFFFF;
|
||
|
}else{
|
||
|
iot_rawdata_set_translate_recv_fc(p_msg);
|
||
|
}
|
||
|
p_msg->profile.irq_type = isr_flag;
|
||
|
g_rawdata.exc_flag |= 0x2000;
|
||
|
}
|
||
|
}
|
||
|
#else
|
||
|
/* set flag, let main loop do work, leave main loop enable intr again */
|
||
|
g_rawdata.dsr_flag = isr_flag;
|
||
|
#endif
|
||
|
|
||
|
g_rawdata.exc_flag |= 0x4000;
|
||
|
/* enable interrupt mask, waiting next turn */
|
||
|
iot_clear_hw_interrupt(isr_flag);
|
||
|
|
||
|
g_rawdata.exc_flag |= 0x8000;
|
||
|
iot_enable_hw_interrupt(isr_flag);
|
||
|
|
||
|
|
||
|
/*enable soc intc vector*/
|
||
|
//iot_rawdata_soc_deattach_isr();
|
||
|
g_rawdata.exc_flag |= 0x10000;
|
||
|
|
||
|
/*should handle record idx here. interrupt also has tick*/
|
||
|
if(isr_flag & INTR_TYPE_MAC_TX_FC){
|
||
|
g_rawdata.exc_flag |= 0x20000;
|
||
|
g_rawdata.txmsg_idx++;
|
||
|
if(g_rawdata.txmsg_idx >= RAWDATA_PROFILE_SLOT_MAX ){
|
||
|
g_rawdata.txmsg_idx = 0;
|
||
|
#ifdef DUMP_TIMING
|
||
|
iot_raw_dump_analysis(INTR_TYPE_MAC_TX_FC);
|
||
|
#endif
|
||
|
}
|
||
|
}
|
||
|
if(isr_flag & INTR_TYPE_MAC_TX_SACK_FC){
|
||
|
g_rawdata.exc_flag |= 0x40000;
|
||
|
g_rawdata.ackmsg_idx++;
|
||
|
if(g_rawdata.ackmsg_idx >= RAWDATA_PROFILE_SLOT_MAX){
|
||
|
g_rawdata.ackmsg_idx = 0;
|
||
|
#ifdef DUMP_TIMING
|
||
|
iot_raw_dump_analysis(INTR_TYPE_MAC_TX_SACK_FC);
|
||
|
#endif
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if(isr_flag & INTR_TYPE_PHY_RECV_FC){
|
||
|
g_rawdata.exc_flag |= 0x80000;
|
||
|
g_rawdata.recmsg_idx++;
|
||
|
if(g_rawdata.recmsg_idx >= RAWDATA_PROFILE_SLOT_MAX){
|
||
|
g_rawdata.recmsg_idx = 0;
|
||
|
#ifdef DUMP_TIMING
|
||
|
iot_raw_dump_analysis(INTR_TYPE_PHY_RECV_FC);
|
||
|
#endif
|
||
|
}
|
||
|
}
|
||
|
|
||
|
g_rawdata.exc_flag |= 0x100000;
|
||
|
return ERR_OK;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
int main(void)
|
||
|
{
|
||
|
uint32_t ret = ERR_FAIL;
|
||
|
fc_trans_msg *p_msg = NULL;
|
||
|
uint32_t src_prot = 0;
|
||
|
uint32_t trans_prot = 0;
|
||
|
uint32_t isr_flag =0;
|
||
|
uint32_t i = 0;
|
||
|
|
||
|
|
||
|
i = i;
|
||
|
|
||
|
/* enable uart1 to output debug message */
|
||
|
//uart_gpio_sel();
|
||
|
//dbg_uart_init();
|
||
|
|
||
|
iot_printf("irq_loop:0x%x, g_rawdata:0x%x txmsg:0x%x ack_msg:0x%x rec_msg:0x%x", &int_loop, &g_rawdata,
|
||
|
g_rawdata.tx_msg, g_rawdata.ack_msg, g_rawdata.rec_msg);
|
||
|
|
||
|
|
||
|
#ifdef IPC_CONTROL
|
||
|
iot_printf("raw_data scpu ipcinit..1..\n");
|
||
|
iot_rawdata_init_ipc(IOT_SECCPU_ID);
|
||
|
|
||
|
while(!rawdata_start_received){
|
||
|
for(i = 0; i<100000; i++);
|
||
|
//iot_printf("waiting start....%d\n", rawdata_start_received);
|
||
|
for(i = 0; i<100000; i++);
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
iot_printf("raw_data dtest beging....\n");
|
||
|
/* Init Context */
|
||
|
iot_rawdata_context_init(&g_rawdata);
|
||
|
|
||
|
src_prot = g_rawdata.src_prot;
|
||
|
trans_prot = g_rawdata.trans_prot;
|
||
|
|
||
|
/* hook up soc interrupt handler*/
|
||
|
iot_printf("raw_data hook soc interrupt...done\n");
|
||
|
iot_rawdata_soc_attach_isr();
|
||
|
iot_rawdata_soc_enable_all_isr();
|
||
|
|
||
|
/* Init MAC PHY */
|
||
|
iot_disable_hw_interrupt(INTR_TYPE_RAW_ALL);
|
||
|
|
||
|
iot_rawdata_hw_set(true, src_prot, trans_prot);
|
||
|
|
||
|
iot_enable_hw_interrupt(INTR_TYPE_RAW_ALL);
|
||
|
iot_printf("raw_data mac/phy interrupt...done\n");
|
||
|
|
||
|
p_msg = p_msg;
|
||
|
isr_flag = isr_flag;
|
||
|
|
||
|
iot_printf("running....\n");
|
||
|
|
||
|
|
||
|
/* Loop */
|
||
|
while(1)
|
||
|
{
|
||
|
#ifndef RUN_MODE_IN_INTERRUPT
|
||
|
if(g_rawdata.dsr_flag){
|
||
|
isr_flag = g_rawdata.dsr_flag;
|
||
|
if(g_rawdata.dsr_flag & INTR_TYPE_MAC_TX_FC ){
|
||
|
/* call do work function here */
|
||
|
p_msg = &g_rawdata.tx_msg[g_rawdata.txmsg_idx];
|
||
|
iot_rawdata_get_tx_fc_bytes(p_msg);
|
||
|
|
||
|
iot_rawdata_translate_tx_fc(p_msg, src_prot, trans_prot);
|
||
|
|
||
|
iot_rawdata_set_translate_tx_fc(p_msg);
|
||
|
|
||
|
g_rawdata.txmsg_idx++;
|
||
|
if(g_rawdata.txmsg_idx >= RAWDATA_PROFILE_SLOT_MAX ){
|
||
|
g_rawdata.txmsg_idx = 0;
|
||
|
}
|
||
|
/*clear dsr_flag */
|
||
|
g_rawdata.dsr_flag &= (~INTR_TYPE_MAC_TX_FC);
|
||
|
}
|
||
|
|
||
|
if(g_rawdata.dsr_flag & INTR_TYPE_MAC_TX_SACK_FC){
|
||
|
/* call do work function here */
|
||
|
p_msg = &g_rawdata.ack_msg[g_rawdata.ackmsg_idx];
|
||
|
|
||
|
iot_rawdata_get_hw_sack_fc_bytes(p_msg);
|
||
|
|
||
|
iot_rawdata_translate_hwsack_fc(p_msg, src_prot, trans_prot);
|
||
|
|
||
|
iot_rawdata_set_translate_sack_fc(p_msg);
|
||
|
|
||
|
g_rawdata.ackmsg_idx++;
|
||
|
if(g_rawdata.ackmsg_idx >= RAWDATA_PROFILE_SLOT_MAX){
|
||
|
g_rawdata.ackmsg_idx = 0;
|
||
|
}
|
||
|
/*clear dsr_flag */
|
||
|
g_rawdata.dsr_flag &= (~INTR_TYPE_MAC_TX_SACK_FC);
|
||
|
}
|
||
|
|
||
|
if(isr_flag & INTR_TYPE_PHY_RECV_FC){
|
||
|
/* HW Received FC */
|
||
|
p_msg = &g_rawdata.rec_msg[g_rawdata.recmsg_idx];
|
||
|
if(iot_rawdata_get_hw_receive_fc_bytes(p_msg) == ERR_OK){
|
||
|
iot_rawdata_translate_hwrec_fc(p_msg, src_prot, trans_prot);
|
||
|
iot_rawdata_set_translate_recv_fc(p_msg);
|
||
|
}
|
||
|
g_rawdata.recmsg_idx++;
|
||
|
|
||
|
if(g_rawdata.recmsg_idx >= RAWDATA_PROFILE_SLOT_MAX){
|
||
|
g_rawdata.recmsg_idx = 0;
|
||
|
}
|
||
|
}
|
||
|
/*enable interrupt */
|
||
|
iot_enable_hw_interrupt(isr_flag);
|
||
|
}
|
||
|
#else
|
||
|
|
||
|
//iot_printf("alive..\n");
|
||
|
for(i = 0; i<100000; i++);
|
||
|
for(i = 0; i<100000; i++);
|
||
|
|
||
|
#endif
|
||
|
}
|
||
|
return ret;
|
||
|
}
|
||
|
|
||
|
void uart_gpio_sel()
|
||
|
{
|
||
|
gpio_mtx_enable();
|
||
|
gpio_sig_info_t info1 = {
|
||
|
SIG_TYPE_UART2,
|
||
|
{
|
||
|
{IO_TYPE_OUT, 0, 7, 0xff, 15},
|
||
|
{IO_TYPE_IN, 0, 8, 11, 0xff}
|
||
|
}
|
||
|
};
|
||
|
gpio_module_pin_select(&info1);
|
||
|
gpio_module_sig_select(&info1, GPIO_MTX_MODE_MATRIX);
|
||
|
gpio_sig_info_t info2 = {
|
||
|
SIG_TYPE_UART0,
|
||
|
{
|
||
|
{IO_TYPE_IN, 0, 31, 9, 0xff}
|
||
|
}
|
||
|
};
|
||
|
gpio_module_pin_select(&info2);
|
||
|
gpio_module_sig_select(&info2, GPIO_MTX_MODE_CORE);
|
||
|
}
|
||
|
|
||
|
uint32_t iot_rawdata_soc_attach_isr(void)
|
||
|
{
|
||
|
/*
|
||
|
static iot_irq_t mac_txfc_irqhdl;
|
||
|
static iot_irq_t mac_txsackfc_irqhdl;
|
||
|
static iot_irq_t phy_recfc_irqhdl;
|
||
|
static iot_irq_t phy_recfc_timeouthdl;
|
||
|
static iot_irq_t phy_txfc_timeouthdl;
|
||
|
*/
|
||
|
mac_txfc_irqhdl = iot_interrupt_create(IRQ_NUM_MAC_TXFC, HAL_INTR_PRI_6,
|
||
|
0, iot_rawdata_interrupt_handler);
|
||
|
|
||
|
iot_interrupt_set_cpu(mac_txfc_irqhdl, HAL_INTR_CPU_1);
|
||
|
iot_printf("hook mac_txfc_irqhdl\n");
|
||
|
|
||
|
iot_interrupt_attach(mac_txfc_irqhdl);
|
||
|
|
||
|
|
||
|
mac_txsackfc_irqhdl = iot_interrupt_create(IRQ_NUM_MAC_TXSACK_FC, HAL_INTR_PRI_6,
|
||
|
0, iot_rawdata_interrupt_handler);
|
||
|
iot_interrupt_set_cpu(mac_txsackfc_irqhdl, HAL_INTR_CPU_1);
|
||
|
|
||
|
iot_printf("hook mac_txsackfc_irqhdl\n");
|
||
|
iot_interrupt_attach(mac_txsackfc_irqhdl);
|
||
|
|
||
|
|
||
|
phy_recfc_irqhdl = iot_interrupt_create(IRQ_NUM_PHY_REC_FC, HAL_INTR_PRI_6,
|
||
|
0, iot_rawdata_interrupt_handler);
|
||
|
|
||
|
iot_interrupt_set_cpu(phy_recfc_irqhdl, HAL_INTR_CPU_1);
|
||
|
iot_printf("hook phy_recfc_irqhdl\n");
|
||
|
iot_interrupt_attach(phy_recfc_irqhdl);
|
||
|
|
||
|
phy_recfc_timeouthdl = iot_interrupt_create(IRQ_NUM_PHY_RECFC_TIMEOUT, HAL_INTR_PRI_6,
|
||
|
0, iot_rawdata_interrupt_handler);
|
||
|
|
||
|
iot_interrupt_set_cpu(phy_recfc_timeouthdl, HAL_INTR_CPU_1);
|
||
|
|
||
|
iot_printf("hook phy_recfc_timeouthdl\n");
|
||
|
iot_interrupt_attach(phy_recfc_timeouthdl);
|
||
|
|
||
|
|
||
|
phy_txfc_timeouthdl = iot_interrupt_create(IRQ_NUM_PHY_TXFC_TIMEOUT, HAL_INTR_PRI_6,
|
||
|
0, iot_rawdata_interrupt_handler);
|
||
|
|
||
|
iot_interrupt_set_cpu(phy_txfc_timeouthdl, HAL_INTR_CPU_1);
|
||
|
|
||
|
iot_printf("hook phy_txfc_timeouthdl\n");
|
||
|
iot_interrupt_attach(phy_txfc_timeouthdl);
|
||
|
|
||
|
|
||
|
|
||
|
return ERR_OK;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
uint32_t iot_rawdata_soc_deattach_isr(void)
|
||
|
{
|
||
|
/*
|
||
|
static iot_irq_t mac_txfc_irqhdl;
|
||
|
static iot_irq_t mac_txsackfc_irqhdl;
|
||
|
static iot_irq_t phy_recfc_irqhdl;
|
||
|
static iot_irq_t phy_recfc_timeouthdl;
|
||
|
static iot_irq_t phy_txfc_timeouthdl;
|
||
|
*/
|
||
|
|
||
|
|
||
|
/* unhook recv isr */
|
||
|
iot_interrupt_delete(mac_txfc_irqhdl);
|
||
|
iot_interrupt_delete(mac_txsackfc_irqhdl);
|
||
|
iot_interrupt_delete(phy_recfc_irqhdl);
|
||
|
iot_interrupt_delete(phy_recfc_timeouthdl);
|
||
|
iot_interrupt_delete(phy_txfc_timeouthdl);
|
||
|
|
||
|
|
||
|
return ERR_OK;
|
||
|
}
|
||
|
|
||
|
uint32_t iot_rawdata_soc_enable_all_isr(void)
|
||
|
{
|
||
|
iot_printf("iot_rawdata_soc_enable_all_isr\n");
|
||
|
/* enabe hw isr */
|
||
|
iot_interrupt_unmask(mac_txfc_irqhdl);
|
||
|
iot_interrupt_unmask(mac_txsackfc_irqhdl);
|
||
|
iot_interrupt_unmask(phy_recfc_irqhdl);
|
||
|
iot_interrupt_unmask(phy_recfc_timeouthdl);
|
||
|
iot_interrupt_unmask(phy_txfc_timeouthdl);
|
||
|
return ERR_OK;
|
||
|
}
|
||
|
|
||
|
uint32_t iot_rawdata_soc_disable_all_isr(void)
|
||
|
{
|
||
|
iot_printf("iot_rawdata_soc_disable_all_isr\n");
|
||
|
/* disble hw isr */
|
||
|
iot_interrupt_mask(mac_txfc_irqhdl);
|
||
|
iot_interrupt_mask(mac_txsackfc_irqhdl);
|
||
|
iot_interrupt_mask(phy_recfc_irqhdl);
|
||
|
iot_interrupt_mask(phy_recfc_timeouthdl);
|
||
|
iot_interrupt_mask(phy_txfc_timeouthdl);
|
||
|
return ERR_OK;
|
||
|
}
|
||
|
|
||
|
uint32_t iot_rawdata_soc_enable_isr(uint8_t irqnum)
|
||
|
{
|
||
|
uint32_t ret = ERR_FAIL;
|
||
|
switch(irqnum)
|
||
|
{
|
||
|
case IRQ_NUM_MAC_TXFC:
|
||
|
iot_interrupt_unmask(mac_txfc_irqhdl);
|
||
|
ret = ERR_OK;
|
||
|
break;
|
||
|
case IRQ_NUM_MAC_TXSACK_FC:
|
||
|
iot_interrupt_unmask(mac_txsackfc_irqhdl);
|
||
|
ret = ERR_OK;
|
||
|
break;
|
||
|
case IRQ_NUM_PHY_REC_FC:
|
||
|
iot_interrupt_unmask(phy_recfc_irqhdl);
|
||
|
ret = ERR_OK;
|
||
|
break;
|
||
|
case IRQ_NUM_PHY_RECFC_TIMEOUT:
|
||
|
iot_interrupt_unmask(phy_recfc_timeouthdl);
|
||
|
ret = ERR_OK;
|
||
|
break;
|
||
|
case IRQ_NUM_PHY_TXFC_TIMEOUT:
|
||
|
iot_interrupt_unmask(phy_txfc_timeouthdl);
|
||
|
ret = ERR_OK;
|
||
|
break;
|
||
|
|
||
|
}
|
||
|
return ret;
|
||
|
}
|
||
|
|
||
|
uint32_t iot_rawdata_soc_disable_isr(uint8_t irqnum)
|
||
|
{
|
||
|
uint32_t ret = ERR_FAIL;
|
||
|
switch(irqnum)
|
||
|
{
|
||
|
case IRQ_NUM_MAC_TXFC:
|
||
|
iot_interrupt_mask(mac_txfc_irqhdl);
|
||
|
ret = ERR_OK;
|
||
|
break;
|
||
|
case IRQ_NUM_MAC_TXSACK_FC:
|
||
|
iot_interrupt_mask(mac_txsackfc_irqhdl);
|
||
|
ret = ERR_OK;
|
||
|
break;
|
||
|
case IRQ_NUM_PHY_REC_FC:
|
||
|
iot_interrupt_mask(phy_recfc_irqhdl);
|
||
|
ret = ERR_OK;
|
||
|
break;
|
||
|
case IRQ_NUM_PHY_RECFC_TIMEOUT:
|
||
|
iot_interrupt_mask(phy_recfc_timeouthdl);
|
||
|
ret = ERR_OK;
|
||
|
break;
|
||
|
case IRQ_NUM_PHY_TXFC_TIMEOUT:
|
||
|
iot_interrupt_mask(phy_txfc_timeouthdl);
|
||
|
ret = ERR_OK;
|
||
|
break;
|
||
|
|
||
|
}
|
||
|
return ret;
|
||
|
}
|
||
|
|
||
|
|
||
|
|