/* ******************************************************************************* * print_all_usb_reg * * Description: * void * * Parameters: * void * * Return value: * void * * note: * void * ******************************************************************************* */ void print_all_usb_reg(spinlock_t *lock, __u32 usbc_base, __s32 ep_start, __u32 ep_end, char *str) { __u32 i = 0; __u32 old_ep_index = 0; unsigned long flags = 0; if(lock){ spin_lock_irqsave(lock, flags); } DMSG_INFO("\n"); DMSG_INFO("-------------------print_all_usb_reg: %s----------------\n", str); old_ep_index = USBC_Readw(usbc_base + USBC_REG_o_EPIND); for(i = ep_start; i <= ep_end; i++){ print_usb_reg_by_ep(lock, usbc_base, i, str); } USBC_Writew(old_ep_index, (usbc_base + USBC_REG_o_EPIND)); DMSG_INFO("---------------------------------------------------------------------------\n"); DMSG_INFO("\n"); if(lock){ spin_unlock_irqrestore(lock, flags); } return; }
static void __USBC_Host_Rx_ConfigEp(__u32 usbc_base_addr, __u32 ep_index, __u32 ts_mode, __u32 ts_type, __u32 is_double_fifo, __u32 ep_MaxPkt, __u32 interval) { __u16 reg_val = 0; __u16 temp = 0; //--<1>--config rx_csr USBC_Writew((1 << USBC_BP_RXCSR_H_CLEAR_DATA_TOGGLE) | (1 << USBC_BP_RXCSR_H_FLUSH_FIFO), USBC_REG_RXCSR(usbc_base_addr)); if(is_double_fifo){ USBC_Writew((1 << USBC_BP_RXCSR_H_CLEAR_DATA_TOGGLE) | (1 << USBC_BP_RXCSR_H_FLUSH_FIFO), USBC_REG_RXCSR(usbc_base_addr)); } //--<2>--config tx ep max packet reg_val = USBC_Readw(USBC_REG_RXMAXP(usbc_base_addr)); temp = ep_MaxPkt & ((1 << USBC_BP_RXMAXP_PACKET_COUNT) - 1); reg_val |= temp; USBC_Writew(reg_val, USBC_REG_RXMAXP(usbc_base_addr)); //--<3>--config ep transfer type __USBC_Host_Rx_EpType(usbc_base_addr, ep_index, ts_mode, ts_type); //--<4>--config polling interval USBC_Writeb(interval, USBC_REG_RXINTERVAL(usbc_base_addr)); }
static void __USBC_Host_ep0_DisablePing(__u32 usbc_base_addr) { u16 csr0 = 0; csr0 = USBC_Readw(USBC_REG_CSR0(usbc_base_addr)); csr0 |= (1 << USBC_BP_CSR0_H_DisPing); USBC_Writew(csr0, USBC_REG_CSR0(usbc_base_addr)); }
static void __USBC_Dev_Tx_ClearStall(ulong usbc_base_addr) { __u32 reg_val; reg_val = USBC_Readw(USBC_REG_TXCSR(usbc_base_addr)); reg_val &= ~((1 << USBC_BP_TXCSR_D_SENT_STALL)|(1 << USBC_BP_TXCSR_D_SEND_STALL)); USBC_Writew(reg_val, USBC_REG_TXCSR(usbc_base_addr)); }
static void __USBC_Host_ep0_SendSetupPkt(__u32 usbc_base_addr) { __u32 reg_val = 0; reg_val = USBC_Readw(USBC_REG_CSR0(usbc_base_addr)); reg_val |= 1 << USBC_BP_CSR0_H_SetupPkt; reg_val |= 1 << USBC_BP_CSR0_H_TxPkRdy; USBC_Writew(reg_val, USBC_REG_CSR0(usbc_base_addr)); }
static void __USBC_Host_ep0_StatusAfterOut(__u32 usbc_base_addr) { __u32 reg_val = 0; reg_val = USBC_Readw(USBC_REG_CSR0(usbc_base_addr)); reg_val |= 1 << USBC_BP_CSR0_H_ReqPkt; reg_val |= 1 << USBC_BP_CSR0_H_StatusPkt; USBC_Writew(reg_val, USBC_REG_CSR0(usbc_base_addr)); }
static void __USBC_Dev_Tx_WriteDataComplete(ulong usbc_base_addr) { __u16 ep_csr = 0; ep_csr = USBC_Readw(USBC_REG_TXCSR(usbc_base_addr)); ep_csr |= 1 << USBC_BP_TXCSR_D_TX_READY; ep_csr &= ~(1 << USBC_BP_TXCSR_D_UNDER_RUN); USBC_Writew(ep_csr, USBC_REG_TXCSR(usbc_base_addr)); }
static __u32 __USBC_Dev_Tx_IsWriteDataReady(ulong usbc_base_addr) { __u32 temp = 0; temp = USBC_Readw(USBC_REG_TXCSR(usbc_base_addr)); temp &= (1 << USBC_BP_TXCSR_D_TX_READY) | (1 << USBC_BP_TXCSR_D_FIFO_NOT_EMPTY); return temp; }
static void __USBC_Dev_Rx_ReadDataComplete(ulong usbc_base_addr) { __u32 reg_val = 0; //overrun, dataerr is used in iso transfer reg_val = USBC_Readw(USBC_REG_RXCSR(usbc_base_addr)); reg_val &= ~(1 << USBC_BP_RXCSR_D_RX_PKT_READY); reg_val &= ~(1 << USBC_BP_RXCSR_D_OVERRUN); reg_val &= ~(1 << USBC_BP_RXCSR_D_DATA_ERROR); USBC_Writew(reg_val, USBC_REG_RXCSR(usbc_base_addr)); }
static void __USBC_Dev_Tx_ConfigEp(ulong usbc_base_addr, __u32 ts_type, __u32 is_double_fifo, __u32 ep_MaxPkt) { __u16 reg_val = 0; __u16 temp = 0; //--<1>--config tx csr reg_val = (1 << USBC_BP_TXCSR_D_MODE); reg_val |= (1 << USBC_BP_TXCSR_D_CLEAR_DATA_TOGGLE); reg_val |= (1 << USBC_BP_TXCSR_D_FLUSH_FIFO); USBC_Writew(reg_val, USBC_REG_TXCSR(usbc_base_addr)); if(is_double_fifo){ USBC_Writew(reg_val, USBC_REG_TXCSR(usbc_base_addr)); } //--<2>--config tx ep max packet reg_val = USBC_Readw(USBC_REG_TXMAXP(usbc_base_addr)); temp = ep_MaxPkt & ((1 << USBC_BP_TXMAXP_PACKET_COUNT) - 1); reg_val &= ~(0x1fff); //added by jerry reg_val |= temp; USBC_Writew(reg_val, USBC_REG_TXMAXP(usbc_base_addr)); //--<3>--config ep transfer type switch(ts_type){ case USBC_TS_TYPE_ISO: __USBC_Dev_Tx_EnableIsoEp(usbc_base_addr); break; case USBC_TS_TYPE_INT: __USBC_Dev_Tx_EnableIntEp(usbc_base_addr); break; case USBC_TS_TYPE_BULK: __USBC_Dev_Tx_EnableBulkEp(usbc_base_addr); break; default: __USBC_Dev_Tx_EnableBulkEp(usbc_base_addr); } }
void print_usb_reg_by_ep(spinlock_t *lock, __u32 usbc_base, __s32 ep_index, char *str) { __u32 old_ep_index = 0; DMSG_INFO("\n"); DMSG_INFO("--------------------------ep%d: %s--------------------------\n", ep_index, str); if (ep_index >= 0) { old_ep_index = USBC_Readw(usbc_base + USBC_REG_o_EPIND); USBC_Writew(ep_index, (usbc_base + USBC_REG_o_EPIND)); DMSG_INFO("old_ep_index = %d, ep_index = %d\n", old_ep_index, ep_index); } DMSG_INFO("USBC_REG_o_FADDR = 0x%x\n", USBC_Readb(usbc_base + USBC_REG_o_FADDR)); DMSG_INFO("USBC_REG_o_PCTL = 0x%x\n", USBC_Readb(usbc_base + USBC_REG_o_PCTL)); DMSG_INFO("USBC_REG_o_INTTx = 0x%x\n", USBC_Readw(usbc_base + USBC_REG_o_INTTx)); DMSG_INFO("USBC_REG_o_INTRx = 0x%x\n", USBC_Readw(usbc_base + USBC_REG_o_INTRx)); DMSG_INFO("USBC_REG_o_INTTxE = 0x%x\n", USBC_Readw(usbc_base + USBC_REG_o_INTTxE)); DMSG_INFO("USBC_REG_o_INTRxE = 0x%x\n", USBC_Readw(usbc_base + USBC_REG_o_INTRxE)); DMSG_INFO("USBC_REG_o_INTUSB = 0x%x\n", USBC_Readb(usbc_base + USBC_REG_o_INTUSB)); DMSG_INFO("USBC_REG_o_INTUSBE = 0x%x\n", USBC_Readb(usbc_base + USBC_REG_o_INTUSBE)); DMSG_INFO("USBC_REG_o_EPIND = 0x%x\n", USBC_Readw(usbc_base + USBC_REG_o_EPIND)); DMSG_INFO("USBC_REG_o_TXMAXP = 0x%x\n", USBC_Readw(usbc_base + USBC_REG_o_TXMAXP)); DMSG_INFO("USBC_REG_o_CSR0 = 0x%x\n", USBC_Readw(usbc_base + USBC_REG_o_CSR0)); DMSG_INFO("USBC_REG_o_TXCSR = 0x%x\n", USBC_Readw(usbc_base + USBC_REG_o_TXCSR)); DMSG_INFO("USBC_REG_o_RXMAXP = 0x%x\n", USBC_Readw(usbc_base + USBC_REG_o_RXMAXP)); DMSG_INFO("USBC_REG_o_RXCSR = 0x%x\n", USBC_Readw(usbc_base + USBC_REG_o_RXCSR)); DMSG_INFO("USBC_REG_o_COUNT0 = 0x%x\n", USBC_Readw(usbc_base + USBC_REG_o_COUNT0)); DMSG_INFO("USBC_REG_o_RXCOUNT = 0x%x\n", USBC_Readw(usbc_base + USBC_REG_o_RXCOUNT)); DMSG_INFO("USBC_REG_o_TXTYPE = 0x%x\n", USBC_Readb(usbc_base + USBC_REG_o_TXTYPE)); DMSG_INFO("USBC_REG_o_NAKLIMIT0 = 0x%x\n", USBC_Readb(usbc_base + USBC_REG_o_NAKLIMIT0)); DMSG_INFO("USBC_REG_o_TXINTERVAL = 0x%x\n", USBC_Readb(usbc_base + USBC_REG_o_TXINTERVAL)); DMSG_INFO("USBC_REG_o_RXTYPE = 0x%x\n", USBC_Readb(usbc_base + USBC_REG_o_RXTYPE)); DMSG_INFO("USBC_REG_o_RXINTERVAL = 0x%x\n", USBC_Readb(usbc_base + USBC_REG_o_RXINTERVAL)); DMSG_INFO("USBC_REG_o_CONFIGDATA = 0x%x\n", USBC_Readb(usbc_base + USBC_REG_o_CONFIGDATA)); DMSG_INFO("USBC_REG_o_DEVCTL = 0x%x\n", USBC_Readb(usbc_base + USBC_REG_o_DEVCTL)); DMSG_INFO("USBC_REG_o_TXFIFOSZ = 0x%x\n", USBC_Readb(usbc_base + USBC_REG_o_TXFIFOSZ)); DMSG_INFO("USBC_REG_o_RXFIFOSZ = 0x%x\n", USBC_Readb(usbc_base + USBC_REG_o_RXFIFOSZ)); DMSG_INFO("USBC_REG_o_TXFIFOAD = 0x%x\n", USBC_Readw(usbc_base + USBC_REG_o_TXFIFOAD)); DMSG_INFO("USBC_REG_o_RXFIFOAD = 0x%x\n", USBC_Readw(usbc_base + USBC_REG_o_RXFIFOAD)); DMSG_INFO("USBC_REG_o_VEND0 = 0x%x\n", USBC_Readb(usbc_base + USBC_REG_o_VEND0)); DMSG_INFO("USBC_REG_o_VEND1 = 0x%x\n", USBC_Readb(usbc_base + USBC_REG_o_VEND1)); DMSG_INFO("TXFADDRx(%d) = 0x%x\n", ep_index, USBC_Readb(usbc_base + USBC_REG_o_TXFADDRx)); DMSG_INFO("TXHADDRx(%d = 0x%x\n", ep_index, USBC_Readb(usbc_base + USBC_REG_o_TXHADDRx)); DMSG_INFO("TXHPORTx(%d) = 0x%x\n", ep_index, USBC_Readb(usbc_base + USBC_REG_o_TXHPORTx)); DMSG_INFO("RXFADDRx(%d) = 0x%x\n", ep_index, USBC_Readb(usbc_base + USBC_REG_o_RXFADDRx)); DMSG_INFO("RXHADDRx(%d) = 0x%x\n", ep_index, USBC_Readb(usbc_base + USBC_REG_o_RXHADDRx)); DMSG_INFO("RXHPORTx(%d) = 0x%x\n", ep_index, USBC_Readb(usbc_base + USBC_REG_o_RXHPORTx)); DMSG_INFO("RPCOUNTx(%d) = 0x%x\n", ep_index, (u32)USBC_Readl(usbc_base + USBC_REG_o_RPCOUNT)); DMSG_INFO("USBC_REG_o_ISCR = 0x%x\n", (u32)USBC_Readl(usbc_base + USBC_REG_o_ISCR)); DMSG_INFO("USBC_REG_o_PHYCTL = 0x%x\n", (u32)USBC_Readl(usbc_base + USBC_REG_o_PHYCTL)); DMSG_INFO("USBC_REG_o_PHYBIST = 0x%x\n", (u32)USBC_Readl(usbc_base + USBC_REG_o_PHYBIST)); if (ep_index >= 0) { USBC_Writew(old_ep_index, (usbc_base + USBC_REG_o_EPIND)); } DMSG_INFO("---------------------------------------------------------------------------\n"); DMSG_INFO("\n"); return; }