Beispiel #1
0
/**
* \brief      This API sets the DMA mode for each channel
*
* \param      dmaMde :- mode for rx and Tx.
*
*\param      epInfo:- End point info structure
*
* \return      None.
*
**/
void Cppi41DmaModeSet(unsigned short usbDevInst, endpointInfo *epInfo)
{

    usbInstance *usbInstance;

    usbInstance = &(cppiInfo.usbInst[usbDevInst]);

    /* Enable RNDIS from Global Level */
    if (epInfo->dmaMode == CPDMA_MODE_SET_RNDIS)
    {
        HWREG(usbInstance->otgBaseAddress + USB_0_CTRL)|=
            CPDMA_MODE_ENABLE_GLOBAL_RNDIS;
    }

    /* Disable RNDIS from Global Level     */
    else
    {
        HWREG(usbInstance->otgBaseAddress + USB_0_CTRL)&=
            ~CPDMA_MODE_ENABLE_GLOBAL_RNDIS;
    }

    /*Set the mode for RX and TX channel */
    if(epInfo->direction == CPDMA_DIR_TX)
    {
        HWREG(usbInstance->otgBaseAddress + USB_0_MODE)|=
            (epInfo->dmaMode << USB_TX_MODE_SHIFT(epInfo->endPoint));
    }

    else
    {
        HWREG(usbInstance->otgBaseAddress + USB_0_MODE)|=
            (epInfo->dmaMode<< USB_RX_MODE_SHIFT(epInfo->endPoint));
    }

    /* For GRNDIS mode, set the maximum packet length */
    if (epInfo->dmaMode == CPDMA_MODE_SET_GRNDIS)
    {
        if(usbDevInst == 0)
        {
            HWREG(usbInstance->otgBaseAddress + USB_0_GEN_RNDIS_SIZE_EP1) =
                GRNDIS_MAX_PACKET_LENGTH;
        }
        else if(usbDevInst == 1)
        {
#if defined (am335x_15x15) || defined(am335x) || defined(c6a811x)
            HWREG(usbInstance->otgBaseAddress + USB_1_GEN_RNDIS_SIZE_EP1) =
                GRNDIS_MAX_PACKET_LENGTH;
#endif
        }
    }
}
static void cppi41_mode_update(struct cppi41_channel *cppi_ch, u8 mode)
{
	if (mode != cppi_ch->dma_mode) {
		struct cppi41 *cppi = cppi_ch->channel.private_data;
		void *__iomem reg_base = cppi->musb->ctrl_base;
		u32 reg_val;
		u8 ep_num = cppi_ch->ch_num + 1;

		if (cppi_ch->transmit) {
			reg_val = musb_readl(reg_base, USB_TX_MODE_REG);
			reg_val &= ~USB_TX_MODE_MASK(ep_num);
			reg_val |= mode << USB_TX_MODE_SHIFT(ep_num);
			musb_writel(reg_base, USB_TX_MODE_REG, reg_val);
		} else {
			reg_val = musb_readl(reg_base, USB_RX_MODE_REG);
			reg_val &= ~USB_RX_MODE_MASK(ep_num);
			reg_val |= mode << USB_RX_MODE_SHIFT(ep_num);
			musb_writel(reg_base, USB_RX_MODE_REG, reg_val);
		}
		cppi_ch->dma_mode = mode;
	}
}