Coder Social home page Coder Social logo

template_dev_driver's Introduction

Character Driver /dev Kernel Module Example

This driver allows controlling of the ip core through,

  1. devicetree
  2. /sys/device/virtual
  3. ioctls

The driver will be mounted as

/dev/templateDriver_0x<fpga mmap address>

Control through /sys/device/virtual

User can read and write registers and bit fields through the virtual sysfs directory. For example

$ pwd
/sys/devices/virtual/templateDriver/templateDriver_0x43c00000/ip_registers
$ ls -la
total 0
drwxr-xr-x    2 root     root             0 Jan  1 00:14 .
drwxr-xr-x    4 root     root             0 Jan  1 00:00 ..
-r--r--r--    1 root     root          4096 Jan  1 00:14 fpga_addr
--w-------    1 root     root          4096 Jan  1 00:14 reset
-rw-r--r--    1 root     root          4096 Jan  1 00:14 template_dts_entry
$ cat fpga_addr
0x43c00000
$ echo 1 > reset

ioctl commands

All ioctl commands can be viewed in template-driver.h. Example code for using the ioctls can be seen in apps/template-test.c.

Device Tree Doc

Template Driver Device Tree Doc

Required properties: - compatible: Should be "usr,template-core" - interrupt-names: Should be "interrupt" - interrupt-parent: Should be <&intc> - interrupts: Should contain interrupts lines. - reg: Should contain registers location and length. - usr,template-dts-entry: used to test grabbing data from devicetree in kmod

Example:

template-core0: template-core@43c00000 {
        compatible = "usr,template-core";
        interrupt-names = "interrupt";
        interrupt-parent = <&intc>;
        interrupts = <0 29 4>;
        reg = <0x43c00000 0x10000>;
        usr,template-dts-entry = <400>;
};

template_dev_driver's People

Contributors

gutelfuldead avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.