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

[gpio] Incorrect register mask values in specification #41

Closed
gaurangchitroda opened this issue Jun 13, 2019 · 9 comments · Fixed by #1670
Closed

[gpio] Incorrect register mask values in specification #41

gaurangchitroda opened this issue Jun 13, 2019 · 9 comments · Fixed by #1670
Assignees
Labels
Component:Tooling Issues related to tooling, e.g. tools/scripts for doc, code generation (docgen, reggen), CSR Priority:P3 Priority: low Type:Bug Bugs

Comments

@gaurangchitroda
Copy link
Contributor

Hi Eunchan,

Register Mask values for following GPIO registers seem incorrect to me:
(1) gpio.INTR_STATE @ + 0x0
mask 0x1
(2) gpio.INTR_ENABLE @ + 0x4
mask 0x1
(3) gpio.INTR_TEST @ + 0x8
mask 0x1

For all 3 registers above, I think that mask value should be 0xffff_ffff as all 32-bits are defined.
I am not sure whether mask means represents "defined"/"unreserved" bits or "writable bits"?
Also, I see "Register enable =" in all registers. Are we missing some information here?

Best Regards,
Gaurang

@mdhayter
Copy link
Contributor

Those are auto generated registers. Looks like there is a bug in the bit expansion.

The bogus Register enable= should not be there anymore (it isn't in the version on bubble), the fix for that went in a couple of weeks ago.

@gaurangchitroda
Copy link
Contributor Author

Hi Mark,

Thanks for your reply. I see "Register enable=" removed after refreshing the page.
Can you please also check if mask 0x0 for gpio.DATA_IN is correct value?

Best Regards,
Gaurang

@gaurangchitroda
Copy link
Contributor Author

@mdhayter @eunchan - Can you please clarify on mask values for INTR_STATE, INTR_ENABLE and INTR_TEST? For GPIO, all 32-bits of these register are writable, so I believe their mask values should be 0xffff_ffff.
I see that corresponding UART registers have mask values equal to 0xff as bits [7:0] are writable.

@lowrisc-bot lowrisc-bot transferred this issue from another repository Aug 31, 2019
@eunchan
Copy link
Contributor

eunchan commented Sep 17, 2019

Sorry for the delayed response. Could you please point the location of mask info? I cannot find in the c header, nor RTL (gpio_reg_pkg.sv)

@gaurangchitroda
Copy link
Contributor Author

gaurangchitroda commented Oct 17, 2019

Sorry for missing your reply on this, please refer to following part in specification:
image

I am not able to point to the same in gpio.md file, but I can see the following in uart.md:

void uart_interrupt_routine() {
  volatile uint32 intr_state = *UART_INTR_STATE_REG;
  uint32 intr_state_mask = 0;
  char uart_ch;
  uint32 intr_enable_reg;

  // Turn off Interrupt Enable
  intr_enable_reg = *UART_INTR_ENABLE_REG;
  *UART_INTR_ENABLE_REG = intr_enable_reg & 0xFFFFFF00; // Clr bits 7:0

  if (intr_state & UART_INTR_STATE_RX_PARITY_ERR_MASK) {
    // Do something ...

    // Store Int mask
    intr_state_mask |= UART_INTR_STATE_RX_PARITY_ERR_MASK;
  }

  if (intr_state & UART_INTR_STATE_RX_BREAK_ERR_MASK) {
    // Do something ...

    // Store Int mask
    intr_state_mask |= UART_INTR_STATE_RX_BREAK_ERR_MASK;
  }

  // .. Frame Error

  // TX/RX Overflow Error

  // RX Int
  if (intr_state & UART_INTR_STATE_RX_WATERMARK_MASK) {
    while(1) {
      uart_ch = uart_rcv_char();
      if (uart_ch == 0xff) break;
      uart_buf.append(uart_ch);
    }
    // Store Int mask
    intr_state_mask |= UART_INTR_STATE_RX_WATERMARK_MASK;
  }

  // Clear Interrupt State
  *UART_INTR_STATE_REG = intr_state_mask;

  // Restore Interrupt Enable
  *UART_INTR_ENABLE_REG = intr_enable_reg;
}

I am not sure if this is relevant (I do not understand *.md files that well), but I think we are populating mask value for INTR_STATE register.
We do not have similar thing in gpio or rv_timer INTR_STATE registers and I think because of this we are seeing default value of mask which is 0x1.
In case of rv_timer, it is correct because there is only single interrupt bit that can be updated and written.
However, gpio has all bits of INTR_STATE register that can be set and cleared.
The same problem exists in INTR_TEST and INTR_ENABLE registers, too.

@eunchan
Copy link
Contributor

eunchan commented Oct 17, 2019

That is due to the multibit of interrupt signal. Let me take a look at auto interrupt register generation code.

@eunchan eunchan added Component:Tooling Issues related to tooling, e.g. tools/scripts for doc, code generation (docgen, reggen), CSR Priority:P3 Priority: low and removed Component:Doc Documentation issue Priority:P1 Priority: high labels Oct 30, 2019
@eunchan eunchan self-assigned this Oct 30, 2019
@aytong
Copy link

aytong commented Oct 31, 2019

@eunchan this was discussed in the GPIO V3 signoff review. Please create an new issue on reggen update, and close this. Thx.

@aytong
Copy link

aytong commented Nov 27, 2019

@eunchan, ping.

@sjgitty
Copy link
Contributor

sjgitty commented Jan 3, 2020

@eunchan what is the status on this old bug?

@eunchan eunchan closed this as completed in 8194985 Mar 4, 2020
jwnrt pushed a commit to jwnrt/opentitan that referenced this issue Feb 1, 2023
Add clickable diagram to documentation landing page
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component:Tooling Issues related to tooling, e.g. tools/scripts for doc, code generation (docgen, reggen), CSR Priority:P3 Priority: low Type:Bug Bugs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants