Skip to content

Instantly share code, notes, and snippets.

@slpp95prashanth
Last active August 21, 2023 09:29
Show Gist options
  • Save slpp95prashanth/7ef0f387650c425bb25d0563106220b2 to your computer and use it in GitHub Desktop.
Save slpp95prashanth/7ef0f387650c425bb25d0563106220b2 to your computer and use it in GitHub Desktop.
VIM Design Documentation and working

VIM Design Documentation

Files:

  • Source File: drivers/interrupt_controller/intc_vim.c
  • Include File: include/zephyr/drivers/interrupt_controller/intc_vim.h

Device Tree:

• dts/arm/ti/tda4vm.dtsi
      vim: interrupt-controller@ff80000 {                                         
            compatible = "arm,vim";                                                   
            reg = <0x0ff80000 0x2800>;                                                
            interrupt-controller;                                                     
            #interrupt-cells = <4>; /* {IRQ/FIQ, IRQ_NUM, IRQ_TYPE, IRQ_PRIO} */      
            status = "okay";                                                          
          }; 
• include/zephyr/dt-bindings/interrupt-controller/arm-vim.h
• dts/bindings/interrupt-controller/arm,vim.yaml
    ◦ Device tree bindings.

Functions:

  • unsigned int z_vim_irq_get_active(void);
  • void z_vim_irq_eoi(unsigned int irq);
  • void z_vim_irq_init(void);
  • void z_vim_irq_priority_set(unsigned int irq, unsigned int prio, uint32_t flags);
  • void z_vim_irq_enable(unsigned int irq);
  • void z_vim_irq_disable(unsigned int irq);
  • int z_vim_irq_is_enabled(unsigned int irq);
  • void z_vim_arm_enter_irq(int irq);

unsigned int z_vim_irq_get_active(void);

Tasks:

  • Read VIM_IRQVEC register (Once the VIM_IRQVEC is read VIM_ACTIRQ gets loaded with the irq number).
  • Get the irq number from the VIM_ACTIRQ register.
  • The IRQSTS is also cleared for the irq number got from the VIM_ACTIRQ.

Return Value:

  • Returns the irq number of interrupt pending with highest priority

void z_vim_irq_eoi(unsigned int irq);

Tasks:

  • Removes the mask for other priority interrupt.

void z_vim_irq_init(void);

Tasks:

  • Compare the number of interrupts supported by the VIM controller (Read VIM_INFO register to get the number of interrupts supported) and CONFIG_NUM_IRQS.
  • Configure default 32 bit aligned interrupt vector address for double bit error in any of the other configured interrupt vector address VIM_DEDVEC.

void z_vim_irq_priority_set(unsigned int irq, unsigned int prio, uint32_t flags);

Tasks:

  • Configure priority (VIM_PRI_INT) and type (pulse or level in VIM_INTTYPE) for the irq number.

void z_vim_irq_enable(unsigned int irq);

Tasks:

  • Enable the interrupt (VIM_INTR_EN_SET) for irq.

void z_vim_irq_disable(unsigned int irq);

Tasks:

  • Disable the interrupt (VIM_INTR_EN_CLR) for irq.

int z_vim_irq_is_enabled(unsigned int irq);

Tasks:

  • Get the interrupt Enabled/Disabled (VIM_INTR_EN_SET) status.

Return:

  • Return 1, if the interrupt enabled for irq.
  • Return 0, if the interrupt disabled for irq.

void z_vim_arm_enter_irq(int irq);

Tasks:

  • Trigger software irq (VIM_RAM).

Adding to the Build:

• drivers/interrupt_controller/Kconfig
    ◦ source "drivers/interrupt_controller/Kconfig.vim"
• drivers/interrupt_controller/Kconfig.vim
      if CPU_CORTEX                                                                                
      config VIM                                                                      
       bool 
      endif # CPU_CORTEX
• drivers/interrupt_controller/CmakeLists.txt
    ◦ zephyr_library_sources_ifdef(CONFIG_VIM  intc_vim.c)
• soc/arm/ti_k3/j721e/Kconfig.series
    ◦ Selecting VIM.

VIM Call Flow

vim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment