> For the complete documentation index, see [llms.txt](https://explore-vineeth.gitbook.io/mywiki/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://explore-vineeth.gitbook.io/mywiki/how-to/access-fifo-registers-as-memory.md).

# Access FIFO Registers as memory

When there are FIFO registers spanning length over 256bytes , it can be a requirement  of the IP to consider this space as memory mapped io.&#x20;

### The steps include

* Map the required register space as sram region
* access the sram node in the ip node
* gen sram\_pool in the driver probe
* pool alloc for the generated sram\_pool

#### DT node&#x20;

```clike
  sram1: sram-reserved@80600040000 {
        compatible = "mmio-sram";
        #address-cells = <2>;
        #size-cells = <2>;
    reg = <0x806 0x00040000 0x00 0xFFFF>;
  };
  mydev:mydev@80600050000 {
          compatible = "cmd,mydev-tmp";
    reg = <0x806 0x00050000 0x00 0x10000>;
    adi,sram = <&sram1>;
  };
```

#### Linux probe code snippet

```c
struct gen_pool *sram_pool;
void __iomem *fifo_base;

/*·Mapping·Funneled·FIFO·as·SRAM·Memory·*/
sram_pool = of_gen_pool_get((&pdev->dev)->of_node, "adi,sram", 0);
if (!sram_pool)·{
    dev_err(&pdev->dev, "Unable·to·get·sram·pool!\n");
    return -ENODEV;
}

/*·Get·the·allocated·virtual·memory·from·sram·pool·*/
fifo_base = (void *)gen_pool_alloc(sram_pool, PAGE_SIZE);
if (!fifo_base) {
    dev_err(&pdev->dev, "Failed·to·alloc·sram·from·sram·pool!\n");
    return PTR_ERR(fifo_base);
}

/* Read the contents. */
if (fifo_base)
    memcpy(buf, fifo_base, size);

/* Free the allocated pool */
if (sram_pool)
    gen_pool_free(sram_pool, (unsigned long)fifo_base, PAGE_SIZE);
```

#### References

<https://wiki.analog.com/resources/tools-software/linuxdsp/docs/linux-kernel-and-drivers/sram>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://explore-vineeth.gitbook.io/mywiki/how-to/access-fifo-registers-as-memory.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
