Kernel Module to support pwm for the sun4i (and others???)
C
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
Kconfig
LICENSE
Makefile
Makefile.kernel
README.md
pwm-sunxi.c
pwm-sunxi.h

README.md

pwm-sunxi

Kernel Module to support pwm for the sun4i (and others???)

Creates a sysfs structure like the following:

   -- pwm-sunxi
      |
      +----pwmX
               |
               +---duty
               +---duty_percent
               +---period
               +---polarity
               +---pulse
               +---pin
               +---run

Period values can be a bit confusing - I have a google spreadsheet that you can use to explore what will happen with different period and duty values

Allwinner A10 Prescale explorer

  • period (r/w)

    period that makes up a cycle. Can be expressed as hz, khz, ms, or us. Whole numbers only.Examples:

    echo 10hz > /sys/class/pwm-sunxi/pwm0/period
    echo 1khz > /sys/class/pwm-sunxi/pwm0/period
    echo 100ms > /sys/class/pwm-sunxi/pwm0/period
    echo 100us > /sys/class/pwm-sunxi/pwm0/period
    echo 150khz > /sys/class/pwm-sunxi/pwm0/period
  • duty (r/w)

    portion of the period above that is "active" or on. Same units as above

  • duty_percent (r/w)

    duty expressed as a percentage. Whole numbers only

    echo 50 > /sys/class/pwm-sunxi/pwm0/duty_percent
  • polarity(r/w)

    polarity of the pin during the duty portion. 1 = high, 0 = low during

  • pulse (r/w)

    Output one pulse at the specified period and duty

  • pin (ro)

    Name of the A10 pin this pwm outputs on. This is hardwired and informational only. Example: PB2

  • run (r/w) Enable the PWM with the previously set parameters. Example:

    echo 1 > /sys/class/pwm-sunxi/pwm0/run
    echo 0 > /sys/class/pwm-sunxi/pwm0/run