opentitan icon indicating copy to clipboard operation
opentitan copied to clipboard

[usbdev] Hook tx_osc_test_mode to register bit?

Open mdhayter opened this issue 6 years ago • 14 comments

There is code in the usb transmitter to continually transmit J/K that is currently tied off in usbdev.sv with: .tx_osc_test_mode_i (1'b0), // cdc ok: quasi-static & testmode only

This should probably go to a bit in phy_config since this will be useful in any real chip to check the USB clock.

mdhayter avatar Jul 04 '20 20:07 mdhayter

Hi @mdhayter, yep, I can definitely connect that. This feature was added by @stefanlippuner originally. I will prepare a PR to get a bit in phy_config next week.

vogelpi avatar Jul 06 '20 20:07 vogelpi

Hi all Yes, that is one of the features that we decided not to upstream. If you'd like it should quite simple to add (e.g. sometime next week). We also excluded my observability and controllability additions to the transceiver interface. Should we also add those? We have since decided to use the controllability to implement remote wakup in software.

stefanlippuner avatar Jul 07 '20 06:07 stefanlippuner

I just created the PR for the osc test mode. I just needed to connect the bit in the phy_config register. Or do you think anything else is needed @stefanlippuner ?

Regarding the other features: could you elaborate a bit? Especially the observability could be interesting for us.

vogelpi avatar Jul 14 '20 17:07 vogelpi

Yes, you can route the signal directly to usb_fs_tx. You could add some synchronization FFs, but I don't think that's strictly necessary here.

We have two additional registers that allow observation (phy_pins_sense) and controlling (phy_pins_drive) of the IO signals. These are then muxed in the usb_iomux with manually instantiated muxes (+synchronization FFs for the sense register). The idea is to use them during the verification (in the next weeks :) ) and potentially also for chip testing.

usb_reg_pins_drive usb_reg_pins_sense

stefanlippuner avatar Jul 15 '20 11:07 stefanlippuner

I am in favour of having the IP include the things that would be needed in a real chip for debug/bringup/characterization so it makes sense to add come of these. I wonder if we want some discussion of this in the comportable IP document?

mdhayter avatar Jul 15 '20 19:07 mdhayter

Sorry @mdhayter and @stefanlippuner , I completely forgot about this issue.

I think we should add these features as well and document them accordingly. I am happy to do the documentation. It would be great if @stefanlippuner could do a PR. Alternatively, I could do it as well but then I would be happy to get some assistance and review support.

vogelpi avatar Sep 23 '20 13:09 vogelpi

It occurs to me that some care will be needed in using the tx_osc_test on chips that make use of the SOF to trim their clock generation -- unless you have done that first the clock could be off. It is still worth putting the feature but probably needs a note in the documentation.

mdhayter avatar Sep 23 '20 17:09 mdhayter

Mark do you mean during such a test mode, there are no longer SOF frames to help calibrate the clock?

On Wed, Sep 23, 2020 at 10:53 AM mdhayter [email protected] wrote:

It occurs to me that some care will be needed in using the tx_osc_test on chips that make use of the SOF to trim their clock generation -- unless you have done that first the clock could be off. It is still worth putting the feature but probably needs a note in the documentation.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lowRISC/opentitan/issues/2703#issuecomment-697788398, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH2RSSX3JHMKOMB4Q6FTS3SHIY25ANCNFSM4OQRPNBA .

tjaychen avatar Sep 23 '20 17:09 tjaychen

This particular bit just causes transmission of alternating J/K (differential 1/0) so there is not real USB activity. This will always allow monitoring of the local clock, but since there is no real traffic there will be no regular SOF to trim the clock. So in a system where you have a local crystal oscillator or an RC that is trimmed in production it will do exactly what is needed. But in a system where the USB clock generation is trimmed using the SOF then you would need a test setup that generates SOF for a while, then removed before this bit is enabled. Would still be useful for seeing the clock is correct and how quickly it moves off-frequency.

mdhayter avatar Sep 23 '20 19:09 mdhayter

sounds good. I guess this will give a good way to see what the calibrated RC is sensitive to as well.

On Wed, Sep 23, 2020 at 12:53 PM mdhayter [email protected] wrote:

This particular bit just causes transmission of alternating J/K (differential 1/0) so there is not real USB activity. This will always allow monitoring of the local clock, but since there is no real traffic there will be no regular SOF to trim the clock. So in a system where you have a local crystal oscillator or an RC that is trimmed in production it will do exactly what is needed. But in a system where the USB clock generation is trimmed using the SOF then you would need a test setup that generates SOF for a while, then removed before this bit is enabled. Would still be useful for seeing the clock is correct and how quickly it moves off-frequency.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lowRISC/opentitan/issues/2703#issuecomment-697937482, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH2RSVPHNRT6PES2GMK3C3SHJG3RANCNFSM4OQRPNBA .

tjaychen avatar Sep 23 '20 20:09 tjaychen

I'll try to put together an MR for the observation/control registers. It's going to be a bit of work, since our two versions have somewhat diverged recently. Two questions:

  • Do you have a primitive for a 2-input mux that the synthesis tool may not touch? We use those to mux these signals (they are effectively clock signals).
  • Is there someone who could test the changes? I don't have an FPGA board for your system.

stefanlippuner avatar Sep 24 '20 14:09 stefanlippuner

This particular bit just causes transmission of alternating J/K (differential 1/0) so there is not real USB activity. This will always allow monitoring of the local clock, but since there is no real traffic there will be no regular SOF to trim the clock. So in a system where you have a local crystal oscillator or an RC that is trimmed in production it will do exactly what is needed. But in a system where the USB clock generation is trimmed using the SOF then you would need a test setup that generates SOF for a while, then removed before this bit is enabled. Would still be useful for seeing the clock is correct and how quickly it moves off-frequency.

Good point. I added this to the documentation.

vogelpi avatar Sep 25 '20 12:09 vogelpi

I'll try to put together an MR for the observation/control registers.

That would be awesome!

It's going to be a bit of work, since our two versions have somewhat diverged recently. Two questions:

* Do you have a primitive for a 2-input mux that the synthesis tool may not touch? We use those to mux these signals (they are effectively clock signals).

We have our abstract primitives for that. You can use hw/ip/prim/prim_clock_mux2.core for that. Note that there is no source file for this. Under the hood, FuseSoC will select the proper technology-specific implementation for it (just the Xilinx implementation is in tree though) or the generic one for simulation. You can have a look at the generic one hw/ip/prim_generic/rtl/prim_generic_clock_mux2.sv to get an idea about the interface.

* Is there someone who could test the changes? I don't have an FPGA board for your system.

I have my NexysVideo board back and could certainly help, but I am missing the PMOD board. @imphil do you know if we still have some lying around in Cambridge?

vogelpi avatar Sep 25 '20 12:09 vogelpi

I am closing this issue has the related PRs have all been merged and Mark also recently re-tested USB functionality on the NexysVideo FPGA board.

vogelpi avatar Jan 04 '21 16:01 vogelpi