Code Monkey home page Code Monkey logo

omap3-pwm's Introduction

omap3 pwm driver

Implements a driver to test the PWM outputs of an OMAP3 based Linux system from userspace.

NOTE

Kernel 3.2 users there is a problem with reloading the driver. The first load is okay and the driver works as described below. If you unload the driver and try to load it again it will fail. Still looking into this. See the notes in Issue 3 for more details.

There is also a new warning when you load the driver

"Disabling lock debugging due to kernel taint"

This is a kernel bug fixed in 3.3 with this commit

https://git.kernel.org/?p=linux/kernel/git/tip/tip.git;a=commit;h=9ec84acee1e221d99dc33237bff5e82839d10cc0

Developers

Scott Ellis, Jack Elston, Curtis Olson

The TI TRM is the reference for all this.

I have some notes for the OMAP3 PWM timers here

http://www.jumpnowtek.com/index.php?option=com_content&view=article&id=56&Itemid=63

Curtis Olson has a relevant PWM/servo article here

http://gallinazo.flightgear.org/technology/gumstix-overo-rc-servos-and-pwm-signal-generation/

The code should work with any OMAP3 board, but primarily tested with Gumstix Overos, a little testing with Beagleboards.

The driver has two modes.

Duty-cycle mode (default) - generates PWM signals with outputs in the range 0-100 duty cycle.

Servo mode - runs at 50 Hz, generating pulses from 1-2 ms in duration by default

Build

There is a ${MACHINE}-source-me.txt file that will set up your environment for the cross-compilation. It assumes you are using an OE environment. Adjust for the build system you are using.

Follow these steps to build.

$ git clone git://github.com/scottellis/omap3-pwm.git
$ cd omap3-pwm

If you have your OE temp directory in a non-standard location, then export an OETMP variable with the path before sourcing the overo-source-me.txt file.

$ [optional] export OETMP=/<your-oetmp-path>

Then

$ source overo-source-me.txt
$ make 

Copy the pwm.ko file to your board.

Once on the system, use insmod to load using the optional parameters.

Driver parameters

timers - A comma separated list of the timers to use, 8-11. The driver will create /dev/pwmXX devices for each timer you enable. The default is all 4 timers. BeagleBoard-XM users want to exclude timer 8. See note below.

Example: timers=8,9,10,11

frequency - non-servo mode only, specify the frequency of the pwm pulse, the default is 1024, the max is 13Mhz / 2.

Example: frequency=1024

servo - Whether to enable servo mode. Values 0 or 1, default is 0.

Example: servo=1

servo_min - Minimum value for servo pulse in tenths of microseconds. The default is 10000 representing 1 ms. The absolute min is 5000 or 0.5 ms.

Example: servo_min=12000

servo_max - Maximum value for servo pulse in tenths of microseconds. The default is 20000 representing 2 ms. The absolute max is 25000 or 2.5 ms.

Example: servo_max=18000

servo_start - Start value for servo pulse in tenths of microseconds. The default is 15000 representing 1.5 ms. Electronic speed controllers might prefer a 1 ms pulse. The range is servo_min to servo_max.

Example: servo_start=10000

nomux - Do not mux the pins for PWM usage. The driver only knows about mux'ing PWM8-11 out the GPIO144-147 (UART2_CTS, UART2_TX) pads, what the Gumstix uses. If you want to use PWM coming off different pads, then either modify the driver or set this flag and make sure the pads are mux'd in another place, like the bootloader or the Linux board init code. Refer to table 7.4 in the OMAP3 TRM and your board documentation. The default is nomux=0 which tells the driver to mux the pins.

Example: nomux=1

Here is an example session with the driver.

root@overo# ls
pwm.ko

root@overo# insmod pwm.ko timers=8,10

The driver will create /dev/pwm8 and /dev/pwm10 in duty-cycle mode.

To issue commands you can use any program that can do file I/O. The standard utilities cat and echo will work.

root@overo# cat /dev/pwm10
0

root@overo# echo 50 > /dev/pwm10

root@overo:~# cat /dev/pwm10
50

root@overo:~# echo 80 > /dev/pwm10

root@overo:~# cat /dev/pwm10
80

In duty-cycle mode, valid settings are in the range 0-100.

You can put an oscope on pin 28 of the Overo expansion board to see the signal for pwm10. Use pin 15 for ground. Or you can measure the voltage on pin 28 and you'll see the duty cycle percentage of 1.8v.

Here are the expansion board pins for all the PWM timers

PWM8  (gpio_147) : pin 29
PWM9  (gpio_144) : pin 30
PWM10 (gpio_145) : pin 28
PWM11 (gpio_146) : pin 27

You have to unload and reload the module to change any of the module parameters.

root@overo:~# rmmod pwm  

root@overo:~# insmod pwm.ko servo=1

This module load tells the driver to create all 4 PWM devices, /dev/pwm8-11, in servo mode.

root@overo:~# echo 12500 > /dev/pwm9

root@overo:~# cat /dev/pwm9
12500

In servo mode the driver starts all PWM at 15000 or 1.5 ms pulse duration which is the standard zero position for servos.

root@overo:~# cat /dev/pwm8
15000

In servo mode the driver wants settings in tenths of microseconds with the default range of 10000 to 20000.

You can pass more then one parameter when you load the driver.

    root@overo:~# insmod pwm.ko servo=1 timers=9,10,11

The driver takes care of muxing the output pins correctly for the Overo boards and restores the original muxing when it unloads. The default muxing by Gumstix for the exposed PWM pins is to be GPIO.

The driver also switches PWM10 and PWM11 to use a 13MHz clock for the source similar to what PWM8 and PWM9 use by default. This is currently not configurable.

Gumstix Note: GPIO 144 and 145, PWM 9 and 10, are used with the lcd touchscreen displays. See board-overo.c in your kernel source for details. You probably don't want to use PWM 9 and 10 at the same time you are using an lcd. I haven't tried it.

BeagleBoard-XM Note: The BeagleBoard-XM uses GPIO 147 for USB reset. This is the same pad the driver muxes for PWM8. You need to explicitly pass a timers parameter to prevent the driver from muxing PWM8 and disabling USB. Timers 9, 10 and 11 can be used.

General BeagleBoard Note: The kernel config option CONFIG_OMAP_RESET_CLOCKS is enabled in the default beagleboard defconfigs. You'll get an oops using pwm.ko with this enabled. This is a kernel power saving feature. You'll need to disable this config option to use this driver. Below is a sample patch for linux-omap-2.6.32's defconfig. Adjust for the kernel you are using. Gumstix users already have this turned off in default kernels.

diff --git a/recipes/linux/linux-omap-2.6.32/beagleboard/defconfig b/recipes/linux/linux-omap-2.6.32/beagleboard/defconfig
index cebe1f5..2dad30c 100644
--- a/recipes/linux/linux-omap-2.6.32/beagleboard/defconfig
+++ b/recipes/linux/linux-omap-2.6.32/beagleboard/defconfig
@@ -241,7 +241,7 @@ CONFIG_ARCH_OMAP3=y
 #
 # CONFIG_OMAP_DEBUG_POWERDOMAIN is not set
 # CONFIG_OMAP_DEBUG_CLOCKDOMAIN is not set
-CONFIG_OMAP_RESET_CLOCKS=y
+# CONFIG_OMAP_RESET_CLOCKS is not set
 # CONFIG_OMAP_MUX is not set
 CONFIG_OMAP_MCBSP=y
 CONFIG_OMAP_MBOX_FWK=m

omap3-pwm's People

Contributors

absci avatar scottellis avatar syntro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

omap3-pwm's Issues

Regarding PWM driver

Hi
Thanks for the info sharing,

i am facing the problem:
root@overo:~# devmem2 0x48086038 w 0xFFFFFFEF
/dev/mem opened.Unhandled fault: external abort on non-linefetch (0x1018) at 0x8

Memory mapped at address 0x40020000.
Bus error

I have configured all pwm as output & mode 2 in u-boot level.
In kernel ,i disabled lcd functionality & touch screen.

But still facing the problem

i am using overo com with summit board.

Awaiting for positive response.
Thank you very much

missing kmalloc and kfree

With the latest stable kernel (2.6.34), kmalloc and kfree functions are not found. Solution: add "#include <linux/slab.h>" in pwm.c.

omap_timer omap_timer.8: omap2_dm_timer_set_src: clk_set_parent() to sys_ck FAILED

Hi,

I compiled the module against a git tree of www.sakoman.com (
http://www.sakoman.com/cgi-bin/gitweb.cgi?p=linux-omap-2.6.git;a=shortlog;h=refs/heads/omap-3.2 ) and tried to use it on my gumstix overo board.

When i try to load the module this error occurs in my dmesg:
omap_timer omap_timer.8: omap2_dm_timer_set_src: clk_set_parent() to sys_ck FAILED

CONFIG_OMAP_RESET_CLOCKS is not set in my kernel-config.

Does the module work with the 3er series of the kernel? Do you have any hints for me whats exactly the problem is?

Thanks so far.

Kind regards,
Alex

plat/dmtimer.h not found

To build against recent kernels, I needed to add this line to the makefile:
ccflags-y += -I$(KERNELDIR)/arch/arm/plat-omap/include

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.