Skip to content

MIU User Guide


REVISION HISTORY

Revision No.
Description
Date
1.0
  • Initial release
  • 05/06/2025

    1. Overview

    Memory Interface Unit, abbreviated as MIU, is primarily responsible for driving DRAM hardware. It provides functions such as initializing DRAM, managing continuous memory regions (MMU), and regulating the priority of direct hardware IP read and write operations.

    图1-1 MIU框架

    2. Keyword Description

    IP : Intellectual Property, which connects various module components of the MIU module.

    ARBITER : An arbiter used to receive and manage requests for memory access from various modules.

    DDRC : Manager, used for handling the access protocol and logical management of DDR memory.

    DDRPHY : A physical channel used to convert the digital logic signals emitted by the DDRC into analog signals that conform to the electrical characteristics of DRAM.

    3. Function Description

    Memory Management Unit (MMU): The MMU is responsible for handling and responding to memory access requests from the Central Processing Unit (CPU).

    Address Protection: Address protection can restrict an IP to only perform fixed-pattern memory access operations. It also provides alerts in case of unexpected behavior.

    Multistage Arbitration: Multistage arbitration typically uses a multi-level arbitration processor to manage memory access requests from IPs.

    Bandwidth Report: The bandwidth report supports real-time statistics on DDR bandwidth usage.

    Supports DDR3/LPDDR3/DDR4/LPDDR4/LPDDR4x and other DDR memory chips.

    Supports low-power design: Power saving can be achieved by controlling the DDR's entry into self-refresh mode.

    4. Kernel Usage Introduction

    4.1. Kernel Config Configuration

    For Linux to use MMU, configuration is required (enabled by default):

    CONFIG_SGS_MIU=y
    

    The configurations selected in menuconfig are as follows:

    Device drivers->
        [*] Sgs SoC platform drivers->
            <*> Sgs MIU
    

    4.2. Module Usage Introduction

    4.2.1 SYSFS Usage Methods

    1. /sys/devices/system/miu/miu0/bist

      Supports configuring simulated IP to access DDR for testing.

      Command format: echo [mode] [rwmode] [bist-x] > /sys/devices/system/miu/miu0/bist

      Parameter
      Description
      Notes
      mode Configurable modes: oneshot (single access) or loop (continuous access)
      rwmode Configurable modes: rw (read-write), wo (write-only), ro (read-only)
      bist-x Configures which BIST to launch: all for all, 0/ 1/ 2 for individual BIST channels Use cat bist node to view each BIST channel's configuration

      Example: Launch all BIST channels for single DDR access

      echo oneshot rw all > /sys/devices/system/miu/miu0/bist

      Example: Launch all BIST channels for continuous DDR access

      Start: echo loop rw all > /sys/devices/system/miu/miu0/bist

      Stop: echo stop all > /sys/devices/system/miu/miu0/bist

    2. /sys/devices/system/miu/miu0/bw

      Supports bandwidth usage statistics.

      Example: Check bandwidth usage

      Configure 128 sampling cycles (default: 32 cycles): echo 128 > /sys/devices/system/miu/miu0/bw

      View collected bandwidth data: cat /sys/devices/system/miu/miu0/bw

    3. /sys/devices/system/miu/miu0/client

      Supports configuring and viewing priority parameters for each client.

      Priority configuration command format: echo qos [rwmode] [clientid] [level] > /sys/devices/system/miu/miu0/client

      Parameter
      Description
      Notes
      rwmode Configurable as r (read) or w (write)
      clientid ID of the IP to be configured
      level Configurable levels 0-7 (0=lowest priority, 7=highest priority)

      Example: Set write priority of bist0 to highest

      echo qos w 0xf 7 > /sys/devices/system/miu/miu0/client

      IP access blocking command format: echo mask [rwmode] [clientid] [enable] > /sys/devices/system/miu/miu0/client

      Parameter
      Description
      Notes
      rwmode Configurable as r (read) or w (write)
      clientid ID of the IP to be configured
      enable 0=disable, 1=enable

      Example: Block write operations of bist0

      echo mask w 0xf 1 > /sys/devices/system/miu/miu0/client

      IP access restriction command format: echo flowctrl [rwmode] [clientid] [enable] [maskperiod] [passperiod] > /sys/ devices/system/miu/miu0/client

      Parameter
      Description
      Notes
      rwmode Configurable as r (read) or w (write)
      clientid ID of the IP to be configured
      enable 0=disable, 1=enable
      maskperiod Blocking period (0-ff) Higher value=stronger restriction
      passperiod Passing period (0-3) Lower value=stronger restriction

      Example: Apply stronger write restrictions to bist0

      Enable: echo flowctrl w 0xf 1 0xff 1 > /sys/devices/system/miu/miu0/client

      Disable: echo flowctrl w 0xf 0 > /sys/devices/system/miu/miu0/client

    4. /sys/devices/system/miu/miu0/dram_info

      Supports viewing current DDR information.

      Example: Check current DDR information

      cat /sys/devices/system/miu/miu0/dram_info

    5. /sys/devices/system/miu/miu0/ip_table

      Supports viewing IP-to-client mapping.

      Example: Check IP-client correspondence

      cat /sys/devices/system/miu/miu0/ip_table

    5. API Reference

    This functional module provides the following interfaces:

    API Function
    drv_miu_module_reset Perform reset based on the IP client name
    drv_miu_module_reset_byid Perform reset based on the IP client id
    drv_miu_module_reset_bymultipleid Perform reset based on the IP client id list
    drv_miu_module_mask Perform mask based on the IP client name
    drv_miu_module_mask_byid Perform mask based on the IP client id
    drv_miu_module_mask_bymultipleid Perform mask based on the IP client id list
    drv_miu_client_id_to_name Obtain the IP client name based on the IP client id
    drv_miu_protect_query Obtain the current free protect id
    drv_miu_protect_enable Enable address protection for the set address range
    drv_miu_protect_disable Disable the address protection for the corresponding protect id
    drv_miu_protect_append_id Add the corresponding IP to the protect list
    drv_miu_protect_remove_id Remove the corresponding IP from the protect list
    drv_miu_protect_default_kernel_whitelist Obtain the current default whitelist
    drv_miu_protect_default_kernel_blacklist Obtain the current default blacklist
    drv_miu_protect_list Retrieve the protection list information based on the protect ID
    drv_miu_protect_status Retrieve the protection status information based on the protect ID
    drv_miu_protect_address Retrieve the protection address information based on the protect ID
    drv_miu_protect_set_panic Enable or disable panic when protection is triggered
    drv_miu_mmu_set_page_size Configure the MMU page size
    drv_miu_mmu_get_page_size Obtain the MMU page size
    drv_miu_mmu_set_region Establish a mapping relationship between VPA and PA regions
    drv_miu_mmu_map_entry Establish a mapping relationship between VPA and PA entries
    drv_miu_mmu_unmap_entry Remove the mapping relationship between VPA and PA entries
    drv_miu_mmu_query_entry Obtain the PA entry id corresponding to the current VPA entry
    drv_miu_mmu_enable Enable or disable MMU functionality
    drv_miu_mmu_reset Reset the MIU
    drv_mmu_callback_func Function about interrupt call for mmu
    drv_miu_dram_info Obtain the parameter information of the currently used DRAM
    drv_miu_init Initialize the MIU
    drv_miu_phy_to_miu Conversion from physical address to MIU address
    drv_miu_addr_to_phy Conversion from MIU address to physical address

    5.1 Client Function Section

    5.1.1 drv_miu_module_reset

    • Function

      Perform reset based on the IP client name.

    • Grammar

      s32 drv_miu_module_reset(char* ClientName, DRV_MIU_OP_MODE Op);
      
    • Parameter

      Parameter name Description Input/Output
      ClientName IP client name Input
      Op operation enum Input

      The details of Op are as shown in the following enumeration types:

      typedef enum
      {
          DRV_MIU_OP_MODE_RD = 0, //read command
          DRV_MIU_OP_MODE_WR, //write command
          DRV_MIU_OP_MODE_MAX, //invalid
      } DRV_MIU_OP_MODE;
      
    • Return Value

      • 0: success

      • Non-zero: failure

    • Rely

      • Header Files: drv_miu.h

    5.1.2 drv_miu_module_reset_byid

    • Function

      Perform reset based on the IP client id.

    • Grammar

      s32 drv_miu_module_reset_byid(miu_client_id ClientID, DRV_MIU_OP_MODE Op);
      
    • Parameter

      Parameter name Description Input/Output
      ClientID IP client id Input
      Op operation enum Input
    • Return Value

      • 0: success

      • Non-zero: failure

    • Rely

      • Header Files: drv_miu.h

    5.1.3 drv_miu_module_reset_bymultipleid

    • Function

      Perform reset based on the IP client id list whose id all belong to the same group.

    • Grammar

      s32 drv_miu_module_reset_bymultipleid(u32 *ClientIDList, u32 ClientIDListLen, DRV_MIU_OP_MODE Op);
      
    • Parameter

      Parameter name Description Input/Output
      ClientIDList IP client id array whose id all belong to the same group Input
      ClientIDListLen IP client id array length Input
      Op operation enum Input
    • Return Value

      • 0: success

      • Non-zero: failure

    • Rely

      • Header Files:drv_miu.h

    5.1.4 drv_miu_module_mask

    • Function

      Perform mask based on the IP client name.

    • Grammar

      s32 drv_miu_module_mask(char *ClientName, DRV_MIU_OP_MODE Op, u8 mask);
      
    • Parameter

      Parameter name Description Input/Output
      ClientName IP client name Input
      Op operation enum Input
      mask open or close mask Input
    • Return Value

      • 0: success

      • Non-zero: failure

    • Rely

      • Header Files: drv_miu.h

    5.1.5 drv_miu_module_mask_byid

    • Function

      Perform mask based on the IP client id.

    • Grammar

      s32 drv_miu_module_mask_byid(miu_client_id ClientID, DRV_MIU_OP_MODE Op, u8 mask);
      
    • Parameter

      Parameter name Description Input/Output
      ClientID IP client id Input
      Op operation enum Input
      mask open or close mask Input
    • Return Value

      • 0: success

      • Non-zero: failure

    • Rely

      • Header Files: drv_miu.h

    5.1.6 drv_miu_module_mask_bymultipleid

    • Function

      Perform mask based on the IP client id list whose id all belong to the same group.

    • Grammar

      s32 drv_miu_module_mask_bymultipleid(u32 *ClientIDList, u32 ClientIDListLen, DRV_MIU_OP_MODE Op, u8 mask);
      
    • Parameter

      Parameter name Description Input/Output
      ClientIDList IP client id array whose id all belong to the same group Input
      ClientIDListLen IP client id array length Input
      Op operation enum Input
      mask open or close mask Input
    • Return Value

      • 0: success

      • Non-zero: failure

    • Rely

      • Header Files:drv_miu.h

    5.1.7 drv_miu_client_id_to_name

    • Function

      Obtain the IP client name based on the IP client id.

    • Grammar

      char* drv_miu_client_id_to_name(u16 id, DRV_MIU_OP_MODE Op);
      
    • Parameter

      Parameter name Description Input/Output
      id IP client id Input
      Op operation enum Input
    • Return Value

      • success: return client name

      • fail: NULL

    • Rely

      • Header Files: drv_miu.h

    5.2 Protect Function Section

    5.2.1 drv_miu_protect_query

    • Function

      Obtain the current free protect id.

    • Grammar

      u8 drv_miu_protect_query(u8 mmu);
      
    • Parameter

      Parameter name Description Input/Output
      mmu Control whether it is MIU protect or MMU protect Input
    • Return Value

      • return protect id
    • Rely

      • Header Files: drv_miu.h

    5.2.2 drv_miu_protect_enable

    • Function

      Enable address protection for the set address range

    • Grammar

      s32 drv_miu_protect_enable(u8 index, u16* list, u8 invert, ss_phys_addr_t start, ss_phys_addr_t end);
      
    • Parameter

      Parameter name Description Input/Output
      index protect id Input
      list The ID list of protected IPs that need to be set Input
      invert Control the whitelist or the blacklist Input
      start Start address Input
      end End address Input
    • Return Value

      • 0: success

      • Non-zero: failure

    • Rely

      • Header Files: drv_miu.h

    5.2.3 drv_miu_protect_disable

    • Function

      Disable the address protection for the corresponding protect id.

    • Grammar

      s32 drv_miu_protect_disable(u8 index);
      
    • Parameter

      Parameter name Description Input/Output
      index protect id Input
    • Return Value

      • 0: success

      • Non-zero: failure

    • Rely

      • Header Files: drv_miu.h

    5.2.4 drv_miu_protect_append_id

    • Function

      Add the corresponding IP to the protect list.

    • Grammar

      s32 drv_miu_protect_append_id(u8 index, u16 id);
      
    • Parameter

      Parameter name Description Input/Output
      index protect id Input
      id IP client id Input
    • Return Value

      • 0: success

      • Non-zero: failure

    • Rely

      • Header Files: drv_miu.h

    5.2.5 drv_miu_protect_remove_id

    • Function

      Remove the corresponding IP from the protect list.

    • Grammar

      s32 drv_miu_protect_remove_id(u8 index, u16 id);
      
    • Parameter

      Parameter name Description Input/Output
      index protect id Input
      id IP client id Input
    • Return Value

      • 0: success

      • Non-zero: failure

    • Rely

      • Header Files: drv_miu.h

    5.2.6 drv_miu_protect_default_kernel_whitelist

    • Function

      Obtain the current default whitelist.

    • Grammar

      u16* drv_miu_protect_default_kernel_whitelist(void);
      
    • Parameter

      • void
    • Return Value

      • Return the ID array of the default whitelist
    • Rely

      • Header Files: drv_miu.h

    5.2.7 drv_miu_protect_default_kernel_blacklist

    • Function

      Obtain the current default blacklist.

    • Grammar

      u16* drv_miu_protect_default_kernel_blacklist(void);
      
    • Parameter

      • void
    • Return Value

      • Return the ID array of the default blacklist
    • Rely

      • Header Files: drv_miu.h

    5.2.8 drv_miu_protect_list

    • Function

      Retrieve the protection list information based on the protect ID.

    • Grammar

      u16* drv_miu_protect_list(u8 index, u8* invert);
      
    • Parameter

      Parameter name Description Input/Output
      index protect id Input
      invert Control the whitelist or the blacklist Input
    • Return Value

      • success: Return the ID array of protect

      • fail: NULL

    • Rely

      • Header Files: drv_miu.h

    5.2.9 drv_miu_protect_status

    • Function

      Retrieve the protection status information based on the protect ID.

    • Grammar

      s32 drv_miu_protect_status(u8 index);
      
    • Parameter

      Parameter name Description Input/Output
      index protect id Input
    • Return Value

      • 0: success

      • Non-zero: failure

    • Rely

      • Header Files: drv_miu.h

    5.2.10 drv_miu_protect_address

    • Function

      Retrieve the protection address information based on the protect ID

    • Grammar

      u16* drv_miu_protect_address(u8 index, ss_phys_addr_t *start, ss_phys_addr_t *end);
      
    • Parameter

      Parameter name Description Input/Output
      index protect id Input
      start start address Output
      end end address Output
    • Return Value

      • 0: success

      • Non-zero: failure

    • Rely

      • Header Files: drv_miu.h

    5.2.11 drv_miu_protect_set_panic

    • Function

      Enable or disable panic when protection is triggered.

    • Grammar

      void drv_miu_protect_set_panic(u8 enable);
      
    • Parameter

      Parameter name Description Input/Output
      enable switch control Input
    • Return Value

      • void
    • Rely

      • Header Files: drv_miu.h

    5.3. MMU Function Section

    5.3.1 drv_miu_mmu_set_page_size

    • Function

      Configure the MMU page size.

    • Grammar

      s32 drv_miu_mmu_set_page_size(u8 page_mode);
      
    • Parameter

      Parameter name Description Input/Output
      page_mode page size Input

      page_mode: MMU_PAGE_SIZE_32K/MMU_PAGE_SIZE_64K/MMU_PAGE_SIZE_128K

    • Return Value

      • 0: success

      • Non-zero: failure

    • Rely

      • Header Files: drv_miu.h

    5.3.2 drv_miu_mmu_get_page_size

    • Function

      Get the MMU page size.

    • Grammar

      u32 drv_miu_mmu_get_page_size(void);
      
    • Parameter

      • void
    • Return Value

      • failure: 0

      • success: Return the current page size

    • Rely

      • Header Files: drv_miu.h

    5.3.3 drv_miu_mmu_set_region

    • Function

      Establish a mapping relationship between VPA (Virtual Physical Address) regions and PA (Physical Address) regions.

    • Grammar

      s32 drv_miu_mmu_set_region(u16 vpa_region, u16 pa_region);
      
    • Parameter

      Parameter name Description Input/Output
      vpa_region vpa region id Input
      pa_region pa region id Input
    • Return Value

      • 0: success

      • Non-zero: failure

    • Rely

      • Header Files: drv_miu.h

    5.3.4 drv_miu_mmu_map_entry

    • Function

      Establish a mapping relationship between VPA (Virtual Physical Address) entries and PA (Physical Address) entries.

    • Grammar

      s32 drv_miu_mmu_map_entry(u16 vpa_entry, u16 pa_entry);
      
    • Parameter

      Parameter name Description Input/Output
      vpa_entry vpa entry id Input
      pa_entry pa entry id Input
    • Return Value

      • 0: success

      • Non-zero: failure

    • Rely

      • Header Files: drv_miu.h

    5.3.5 drv_miu_mmu_unmap_entry

    • Function

      Remove the mapping relationship between VPA (Virtual Physical Address) entries and PA (Physical Address) entries.

    • Grammar

      s32 drv_miu_mmu_unmap_entry(u16 vpa_entry);
      
    • Parameter

      Parameter name Description Input/Output
      vpa_entry vpa entry id Input
    • Return Value

      • 0: success

      • Non-zero: failure

    • Rely

      • Header Files: drv_miu.h

    5.3.6 drv_miu_mmu_query_entry

    • Function

      Obtain the PA (Physical Address) entry id corresponding to the current VPA (Virtual Physical Address) entry.

    • Grammar

      u16 drv_miu_mmu_query_entry(u16 vpa_entry);
      
    • Parameter

      Parameter name Description Input/Output
      vpa_entry vpa entry id Input
    • Return Value

      • return pa entry id
    • Rely

      • Header Files: drv_miu.h

    5.3.7 drv_miu_mmu_enable

    • Function

      Enable or disable MMU functionality.

    • Grammar

      s32 drv_miu_mmu_enable(u8 enable);
      
    • Parameter

      Parameter name Description Input/Output
      enable Switch control Input
    • Return Value

      • 0: success

      • Non-zero: failure

    • Rely

      • Header Files: drv_miu.h

    5.3.8 drv_miu_mmu_reset

    • Function

      Reset the MMU.

    • Grammar

      s32 drv_miu_mmu_reset(void);
      
    • Parameter

      • void
    • Return Value

      • 0: success

      • Non-zero: failure

    • Rely

      • Header Files: drv_miu.h

    5.3.9 drv_mmu_callback_func

    • Function

      Enable or disable MMU functionality.

    • Grammar

      void drv_mmu_callback_func(drv_mmu_irq_callback func);
      
    • Parameter

      Parameter name Description Input/Output
      func Used to describe callback function Input
    • Return Value

      • void
    • Rely

      • Header Files: drv_miu.h

    5.4. Misc Function Section

    5.4.1 drv_miu_dram_info

    • Function

      Obtain the parameter information of the currently used DRAM.

    • Grammar

      s32 drv_miu_dram_info(struct miu_dram_info* dram);
      
    • Parameter

      Parameter name Description Input/Output
      dram dram parameter info Output
    • Return Value

      • 0: success

      • Non-zero: failure

    • Rely

      • Header Files: drv_miu.h

    5.4.2 drv_miu_init

    • Function

      Initialize the MIU.

    • Grammar

      s32 drv_miu_init(void);
      
    • Parameter

      • void
    • Return Value

      • 0: success

      • Non-zero: failure

    • Rely

      • Header Files: drv_miu.h

    5.4.3 drv_miu_phy_to_miu

    • Function

      Conversion from physical address to MIU address.

    • Grammar

      ss_miu_addr_t drv_miu_phy_to_miu(ss_phys_addr_t phy_addr);
      
    • Parameter

      Parameter name Description Input/Output
      phy_addr physical address Input
    • Return Value

      • MIU address
    • Rely

      • Header Files: drv_miu.h

    5.4.4 drv_miu_addr_to_phy

    • Function

      Conversion from MIU address to physical address.

    • Grammar

      ss_phys_addr_t drv_miu_addr_to_phy(ss_miu_addr_t miu_addr);
      
    • Parameter

      Parameter name Description Input/Output
      miu_addr MIU address Input
    • Return Value

      • physical address
    • Rely

      • Header Files: drv_miu.h

    5.5 data structure description

    • Illustrate

      Define DRAM-related parameter information.

    • Definition

      struct miu_dram_info
      {
          u64 size;
          u32 dram_freq;
          u32 miupll_freq;
          u8  type;
          u8  data_rate;
          u8  bus_width;
          u8  ssc;
      };
      
    • Member

      Member Name Description
      size The size of the DRAM, measured in MB
      dram_freq The frequency of the DRAM, measured in MHz
      miupll_freq The frequency of the miupll, measured in MHz
      type The type of DRAM, such as DDR3 or DDR4
      data_rate The transmission mode, which can be 4x mode or 8x mode
      bus_width The transmission bit width, which can be 16 bit, 32 bit, or 64 bit
      ssc Whether spread spectrum is enabled

    6. FAQ

    6.1 Check the current bandwidth usage

    1. Use cat /sys/devices/system/miu/miu0/dram_info to view information related to DDR chips.

    2. Use cat /sys/devices/system/miu/miu0/bw to check the corresponding usage status.

    6.2 Check the current protection configuration information

    It can be viewed through cat /proc/mi_modules/mi_sys_mma/miu_protect.