Project

General

Profile

Include Path / Where is the correct source files?

Added by Brian Rasmussen almost 14 years ago

Hi

I am trying to interface to the FPGA on a MityDSP-L138 board. I have succeeded building a new kernel, inserting the "fpga_ctrl.ko" module into the kernel and loading the FPGA with the IndustrialIO.bin file from the wiki. The green "Done" LED is on, so it worked! :-)

I would now like to extend the "HelloWorld" example and make a connection from my application to the fpga device (EMIF interface). The goal is to make a RAM device in the FPGA, and read/write to it from the uC (through the EMIF).

To get a feeling of how the EMIF works before implementing the RAM device from scratch, I would like to try some of the drivers from the board support package e.g. "fpga.h" or "fpga_gpio.c/h". If I include the fpga.h file (e.g. to try to read out fpga core version), my project is not able to compile. It can't find the include "linux/device.h". I have searched through my machine to find this file, but it exist in several places!

The question is: Which file/directory should I include in Eclipse (include path) to get access to the fpga driver modules?

Second: What is the correct platform include dir for accessing e.g. gpio (MityDSP-L138F board)? I have included the toolchain (usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr/include) as described in the wiki, and I have also included different folders within the ~/linux-davinci/ source but with no luck. Where is the gpio.h file for e.g. the "omap_request_gpio(x)" function?

Thanks in advance.

Best regards
Brian


Replies (6)

RE: Include Path / Where is the correct source files? - Added by Michael Williamson almost 14 years ago

Hi Brian,

Are you trying to write a driver or trying to access the EMIF via your application? Typically, direct memory access must be handled by writing a driver (a kernel module) that supports actions such as mmap (memory mapping). Then your application would open the driver (e.g., fopen("/dev/your_driver") or fopen("/sys/devices/platform/you_driver/...") ) and map in the memory that it wants to look at. This is sort of how the memory management works under the linux OS, user applications are not provided access to physical memory without going through appropriate kernel mechanisms. There is some good reference material about device drivers and kernel modules at lwn.net. When you are building kernel modules, then the kernel module build system is used and the include paths are picked up with the KERNEL_DIR variable (see he build scripts in the fpga modules directory). You can't include "fpga.h" from a user level app, it's not intended to be included for non-kernel-module builds.

The modules we have included to program the FPGA primarily interact with the user via the /sys filesystem. The other modules that implement a "standard" form of IP such as SPI, I2C, or GPIO should plug into the standard linux I/O framework for those buses. Not sure if I've answered your questions yet...

As for the GPIO, you have two choices, you can write a driver module and make the gpio calls similar to those in board-mityomapl138.c, or you can interact with them in userspace via the /sys filesystem. To do either, there are some details about them here. For the userspace access, see the section entitled "Sysfs Interface for Userspace (OPTIONAL)".

Hope this helps.

-Mike

RE: Include Path / Where is the correct source files? - Added by Brian Rasmussen almost 14 years ago

Hi Mike

Thanks for your response. I am trying to access the EMIF from my application. I will prefer not to write any drivers if possible... The information about "fopen" above is exactly what I'm looking for.

The next steps for a simple gpio communication will then be (please correct me if I am wrong):

1. Insert the fpga_gpio.ko into the linux kernel (insmod fpga_gpio.ko)
2. Change my application to access the gpio kernel module via "fopen(/sys/fpga_gpio).
3. Do some gpio stuff in my application (e.g. toggle a pin).
4. Write the FPGA application based on the *.vhd modules provided from you.
5. Debug... Hopefully it will work :-)

You refer to the board-mityomapl138.c file above regarding OMAP gpio. Do I need to include this file or can I just include the /sys/io.h file? Do I need to load any modules into the kernel or is it preloaded?

Best regards,
Brian

RE: Include Path / Where is the correct source files? - Added by Brian Rasmussen almost 14 years ago

Hi Mike

I now have the FPGA communication up and running, and I can toggle an FPGA output pin from the command line (using /sys/class/gpio/...). So far so good! :-)

Next step is to re-work the FPGA modules and the linux drivers... The goal is to have a RAM module in the FPGA mapped into user space ram in my linux application. I have been searching for some code examples for mapping memory into userspace, but with no luck. In the board support package, you have a core id and an FPGA module for a TFP410 DVI controller. I guess this must be using memory mapping and not the /sys filesystem?
Do you have any source code for that, or is it restricted by TI? What about the linux driver for DVI? Is it already implemented, or do I need any special drivers?

What about the linux driver used for communicating with the 256MB NAND flash? Is it possible to use this driver?

I hope you can give me some hints about this.

Best regards.
Brian

RE: Include Path / Where is the correct source files? - Added by Michael Williamson almost 14 years ago

Brian,

Good to hear the gpio is working for you.

You are trying to memory map FPGA space into userspace. The way to go for that is to implement the mmap feature in your kernel driver. I think there are some examples on the web for that, I'll try to post an example when I get some time.

The TFP410 DVI FPGA controller is really empty (it doesn't do anything). It was intended to deal with using 12 or 24 bit data going to the TFP410 (using the DDR mode of the device). We never really implemented that, as all of our designs are using 24 bit mode for the device now. The real device/driver needed for the TFP510 is the LCD controller peripheral that is part of the OMAP-L138 (or AM1808) device itself. All the FPGA does is route the LCD data and strobes off the module. The driver for the TFP410 is the da850 LCD framebuffer driver (drivers/video/da8xx_fb.c). It should show up as /dev/fb0 if you have the kernel configured correctly and u-boot config settings correct. It's all open source, no restrictions.

The linux driver for the NAND is also built into the kernel. The NAND should show up under the /dev/mtd* devices. /dev/mtd0 (or /dev/mtdblock0) as well as /dev/mtd1 (/dev/mtdblock1) should be available. You will need to create a filesystem or mount one (such as jffs2) to use the NAND device.

-Mike

RE: Include Path / Where is the correct source files? - Added by Brian Rasmussen almost 14 years ago

Hi Mike,

I will search the net for a mmap example. Regarding the NAND device it is already mounted.

Thanks for your help so far.

Best regards
Brian

RE: Include Path / Where is the correct source files? - Added by Brian Rasmussen almost 14 years ago

Hi Mike

I have now found out how to map kernel space into user space, though I don't have an example working yet.

Another question has come up: Will I be able to read/write to the FPGA through the EMIFA, if I just map the memory area 0x66000000 (EMIFA CS5) in my application?

In case it should co-exist with your board support package, could I then use EMIFA CS4 at address 0x64000000?

Best regards
Brian

    (1-6/6)
    Go to top
    Add picture from clipboard (Maximum size: 1 GB)