Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[spi_device] Add an enable bit for the IP to prevent partial configuration? #14665

Closed
a-will opened this issue Aug 30, 2022 · 16 comments
Closed
Assignees
Labels
Component:RTL Earlgrey-PROD Candidate Temporary label to triage issues into Earlgrey-PROD Milestones Hotlist:Silicon to be resolved in Silicon Committee IP:spi_device Priority:P3 Priority: low

Comments

@a-will
Copy link
Contributor

a-will commented Aug 30, 2022

For the spi_device IP, should we add an IP-wide enable bit in a CSR? Currently, the spi_device IP is never actually off (power / clock / reset inputs notwithstanding). This means that the spi_device could respond to transactions before the full configuration is ready. Should we gate responses to the host, events on CSRs / interrupts, and the filling of FIFOs until software has a chance to complete configuration?

On the spi_host clock side, this would likely mean sampling the enable bit at the beginning of a transaction and discarding the data if the enable was low.

@a-will
Copy link
Contributor Author

a-will commented Aug 30, 2022

CC @tjaychen @eunchan @jeoongp

@tjaychen
Copy link

tjaychen commented Sep 7, 2022

ah i like this idea...i think it's better than whatever CSb edge hunting idea I had.
To summarize, would it effectively be that when csb goes low and spi_clock starts, everything behaves "as expected" for a couple of cycles. On the second cycle, you will have discovered whether things are enabled vs not, and then perhaps cycle things back from there?

@tjaychen
Copy link

tjaychen commented Sep 7, 2022

@weicaiyang

@tjaychen
Copy link

tjaychen commented Sep 7, 2022

ah i like this idea...i think it's better than whatever CSb edge hunting idea I had. To summarize, would it effectively be that when csb goes low and spi_clock starts, everything behaves "as expected" for a couple of cycles. On the second cycle, you will have discovered whether things are enabled vs not, and then perhaps cycle things back from there?

A number of FSMs and stuff would probably need to be "reset" etc.

@eunchan
Copy link
Contributor

eunchan commented Sep 7, 2022

Should we assign this to "Future Release"? I don't think we have enough time changing the design and review CDC.

@tjaychen
Copy link

tjaychen commented Sep 8, 2022

we might have to quantify the host impact a bit.
Let me ruminate a bit on this offline, since I probably can't put it all in the open.

@weicaiyang weicaiyang modified the milestones: Project: M2, Project: M3 Oct 14, 2022
@eunchan
Copy link
Contributor

eunchan commented Oct 14, 2022

I will add an enable bit to CSR (rather than adding CG to SPI_CLK or OR gate on CSb) that blocks cmdparse to activate any datapaths. It would take less effect to the timing.

eunchan added a commit to eunchan/opentitan that referenced this issue Nov 8, 2022
Applying assumption of tying SCK while resetting chip or IP.
Related issue to folllow up later:
lowRISC#14665 or lowRISC#9503

Signed-off-by: Eli Kim <[email protected]>
eunchan added a commit to eunchan/opentitan that referenced this issue Nov 9, 2022
Applying assumption of tying SCK while resetting chip or IP.
Related issue to folllow up later:
lowRISC#14665 or lowRISC#9503

Signed-off-by: Eli Kim <[email protected]>
eunchan added a commit to eunchan/opentitan that referenced this issue Nov 9, 2022
Applying assumption of tying SCK while resetting chip or IP.
Related issue to folllow up later:
lowRISC#14665 or lowRISC#9503

Signed-off-by: Eli Kim <[email protected]>
eunchan added a commit that referenced this issue Nov 9, 2022
Applying assumption of tying SCK while resetting chip or IP.
Related issue to folllow up later:
#14665 or #9503

Signed-off-by: Eli Kim <[email protected]>
@cindychip cindychip removed the Type:Question Questions label Jan 28, 2023
@andreaskurth
Copy link
Contributor

andreaskurth commented Feb 23, 2023

Triaged for spi_device. Assigning to M2.5 with (existing) Priority:P1 Priority: high because we should clarify with the product team if this is a requirement.

@andreaskurth
Copy link
Contributor

andreaskurth commented Mar 17, 2023

We have to add this enable bit. The proposal is as follows:

Add an enable register field that:

  • resets to 1’b0;
  • gets 2FF-synced to the SPI clock and there resets with rst_ni & ~csb_i (active low) to 1’b0 (The rationale for the reset condition is that the two modules into which the enable signal in the SPI clock domain gets passed, spi_cmdparse and spi_passthrough, are also reset based on the same condition. Using the same reset signal avoids RDC issues.);
  • when 1’b0 in the SPI clock domain, causes a transition to StWait in spi_cmdparse at the end of the command phase (i.e., when the 8th bit is valid);
  • when 1’b0 in the SPI clock domain, causes a transition to StFilter in spi_passthrough at the end of the command phase (i.e., when the 8th bit is valid).

Keeping Priority:P1 Priority: high because this requires an RTL change and subsequent DV changes and functional coverage.

@hcallahan-lowrisc
Copy link
Contributor

estimate 20
remaining 2023-03-22 20

@moidx moidx added Priority:P3 Priority: low and removed Priority:P1 Priority: high labels Apr 5, 2023
@msfschaffner
Copy link
Contributor

It looks like we can reset both spi_device and spi_host via the system reset controls:

{ name: "spi_device", gen: true, type: "top", parent: "lc_src", clk: "io_div4", sw: true }
{ name: "spi_host0", gen: true, type: "top", parent: "lc_src", clk: "io", sw: true }
{ name: "spi_host1", gen: true, type: "top", parent: "lc_src", clk: "io_div2", sw: true }

Hence, even if it would be convenient to implement this in the blocks themselves, there is a workaround for this available, hence I think we can deprioritize this to after M2.5.

@andreaskurth
Copy link
Contributor

It looks like we can reset both spi_device and spi_host via the system reset controls

This also resets spi_device's configuration, right? So when you bring it out of reset, how do you prevent it from doing unintended things until it's fully configured? The enable register field was meant to do that

@msfschaffner
Copy link
Contributor

@andreaskurth you are right, this workaround would only partially address the issue at hand.
To that end, I discussed this some more with @moidx and @a-will to gauge whether we need this for M2.5 or not.
We think we can work around all interesting integration use cases for which M2.5 will be used.

Specifically:

  • TPM mode: can be modulated via IO bit
  • passthrough mode: host can either be reset by OT, or the test can be set up so that OT and the host are properly reset sequenced
  • flash mode: we can control the timing during bootstrap modes
  • generic mode: may be used during manufacturing tests where timing can be controlled explicitly

So, while this is a good feature to have for M3, we decided to de-prioritize this feature for M2.5 and defer it.

@hcallahan-lowrisc
Copy link
Contributor

Related comment : #14861 (review)

@msfschaffner msfschaffner added the Earlgrey-PROD Candidate Temporary label to triage issues into Earlgrey-PROD Milestones label Oct 7, 2023
@a-will
Copy link
Contributor Author

a-will commented Feb 22, 2024

This is likely not necessary. The data sheet will always have a spec requirement to wait some amount of time before transactions are allowed (the "reset delay" or similar). The response to such activity is considered undefined behavior.

We can sweep this sort of configuration need into that time requirement.

@a-will
Copy link
Contributor Author

a-will commented Feb 22, 2024

I'm going to close this, since that time requirement is always present. However, if someone wants to implement this to improve robustness in the future, then we do have a "Disabled" mode now that generic mode is gone. The bits would need to be held steady and sampled at the right moment to allow the transition to the SPI domain, in addition to ensuring the atomicity of SPI transactions.

@a-will a-will closed this as completed Feb 22, 2024
@a-will a-will closed this as not planned Won't fix, can't repro, duplicate, stale Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component:RTL Earlgrey-PROD Candidate Temporary label to triage issues into Earlgrey-PROD Milestones Hotlist:Silicon to be resolved in Silicon Committee IP:spi_device Priority:P3 Priority: low
Projects
None yet
Development

No branches or pull requests

10 participants