Re: [PATCH 10/22] usb: dwc3: gadget: initialize NUMP based on RxFIFO Size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

John Youn <John.Youn@xxxxxxxxxxxx> writes:
>> @@ -1589,6 +1578,46 @@ static void dwc3_gadget_disable_irq(struct dwc3 *dwc)
>>  static irqreturn_t dwc3_interrupt(int irq, void *_dwc);
>>  static irqreturn_t dwc3_thread_interrupt(int irq, void *_dwc);
>>  
>> +/**
>> + * dwc3_gadget_setup_nump - Calculate and initialize NUMP field of DCFG
>> + * dwc: pointer to our context structure
>> + *
>> + * The following looks like complex but it's actually very simple. In order to
>> + * calculate the number of packets we can burst at once on OUT transfers, we're
>> + * gonna use RxFIFO size.
>> + *
>> + * To calculate RxFIFO size we need two numbers:
>> + * MDWIDTH = size, in bits, of the internal memory bus
>> + * RAM2_DEPTH = depth, in MDWIDTH, of internal RAM2 (where RxFIFO sits)
>> + *
>> + * Given these two numbers, the formula is simple:
>> + *
>> + * RxFIFO Size = (RAM2_DEPTH * MDWIDTH / 8) - 24 - 16;
>> + *
>> + * 24 bytes is for 3x SETUP packets
>> + * 16 bytes is a clock domain crossing tolerance
>> + *
>> + * Given RxFIFO Size, NUMP = RxFIFOSize / 1024;
>> + */
>> +static void dwc3_gadget_setup_nump(struct dwc3 *dwc)
>> +{
>> +	u32 ram2_depth;
>> +	u32 mdwidth;
>> +	u32 nump;
>> +	u32 reg;
>> +
>> +	ram2_depth = DWC3_GHWPARAMS7_RAM2_DEPTH(dwc->hwparams.hwparams7);
>> +	mdwidth = DWC3_GHWPARAMS0_MDWIDTH(dwc->hwparams.hwparams0);
>> +
>> +	nump = ((ram2_depth * mdwidth / 8) - 24 - 16) / 1024;
>
> This value should be capped to 16.

I'll add a min() here.

-- 
balbi

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux