LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-04-2012, 01:05 AM   #16
dennisdd
Member
 
Registered: Oct 2011
Posts: 37

Original Poster
Rep: Reputation: Disabled

Code:
# /system/bin/lsmod
/system/bin/lsmod
#
I saw lsmod..
Code:
# ls -l  /system/bin
ls -l  /system/bin
-rwxr-xr-x system   system        191 2010-07-30 05:44 am
-rwxr-xr-x system   system      77300 2010-07-30 05:44 dd
-rwxr-xr-x system   system      77300 2010-07-30 05:44 df
-rwxr-xr-x system   system      77300 2010-07-30 05:44 hd
-rwxr-xr-x system   system      77300 2010-07-30 05:44 id
-rwxr-xr-x system   system      77300 2010-07-30 05:44 ln
-rwxr-xr-x system   system      77300 2010-07-30 05:44 ls
-rwxr-xr-x system   system      77300 2010-07-30 05:44 mv
-rwxr-xr-x system   system        191 2010-07-30 05:44 pm
-rwxr-xr-x system   system      77300 2010-07-30 05:44 ps
-rwxr-xr-x system   system      77300 2010-07-30 05:44 rm
-rwxr-xr-x system   system      91064 2010-07-30 05:44 sh
-rwxr-xr-x system   system      77300 2010-07-30 05:44 getprop
-rwxr-xr-x system   system      76224 2010-07-30 05:44 ash
-rwxr-xr-x system   system      77300 2010-07-30 05:44 cat
-rwxr-xr-x system   system      77300 2010-07-30 05:44 cmp
-rwxr-xr-x system   system       5492 2010-07-30 05:44 dvz
-rwxr-xr-x system   system        194 2010-07-30 05:44 ime
-rwxr-xr-x system   system      77300 2010-07-30 05:44 log
-rwxr-xr-x system   system      77300 2010-07-30 05:44 smd
-rwxr-xr-x system   system        192 2010-07-30 05:44 svc
-rwxr-xr-x system   system      77300 2010-07-30 05:44 top
-rwxr-xr-x system   system      77300 2010-07-30 05:44 setprop
-rwxr-xr-x system   system       5180 2010-07-30 05:44 bluetoothd
-rwxr-xr-x system   system        199 2010-07-30 05:44 bmgr
-rwxr-xr-x system   system      18128 2010-07-30 05:44 chat
-rwxr-xr-x system   system      77300 2010-07-30 05:44 date
-rwxr-xr-x system   system      27060 2010-07-30 05:44 dund
-rwxr-xr-x system   system      26892 2010-07-30 05:44 hidd
-rwxr-xr-x system   system       5528 2010-07-30 05:44 gzip
-rwxr-xr-x system   system      77300 2010-07-30 05:44 kill
-rwxr-xr-x system   system      18244 2010-07-30 05:44 mtpd
-rwxr-xr-x system   system      26940 2010-07-30 05:44 pand
-rwxr-xr-x system   system      26648 2010-07-30 05:44 ping
-rwxr-xr-x system   system     151760 2010-07-30 05:44 pppd
-rwxr-xr-x system   system       5592 2010-07-30 05:44 rild
-rwxr-xr-x system   system      77300 2010-07-30 05:44 stop
-rwxr-xr-x system   system      77300 2010-07-30 05:44 sync
-rwxr-xr-x system   system      47316 2010-07-30 05:44 vold
-rwxr-xr-x system   system      77300 2010-07-30 05:44 wipe
-rwxr-xr-x system   system      77300 2010-07-30 05:44 netstat
-rwxr-xr-x system   system       9820 2010-07-30 05:44 dumpsys
-rwxr-xr-x system   system      77300 2010-07-30 05:44 watchprops
-rwxr-xr-x system   system      22160 2010-07-30 05:44 debuggerd
-rwxr-xr-x system   system      77300 2010-07-30 05:44 toolbox
-rwxr-xr-x system   system       5516 2010-07-30 05:44 dalvikvm
-rwxr-xr-x system   system       5424 2010-07-30 05:44 radiooptions
-rwxr-xr-x system   system     104960 2010-07-30 05:44 iptables
-rwxr-xr-x system   system      77300 2010-07-30 05:44 insmod
-rwxr-xr-x system   system       5468 2010-07-30 05:44 faketsd
-rwxr-xr-x system   system      80740 2010-07-30 05:44 dbus-daemon
-rwxr-xr-x system   system        205 2010-07-30 05:44 spp_test
-rwxr-xr-x system   system      77300 2010-07-30 05:44 schedtop
-rwxr-xr-x system   system      64244 2010-07-30 05:44 linker
-rwxr-xr-x system   system      22572 2010-07-30 05:44 fsck_msdos
-rwxr-xr-x system   system       9704 2010-07-30 05:44 logwrapper
-rwxr-xr-x system   system       9764 2010-07-30 05:44 logcat
-rwxr-xr-x system   system      23124 2010-07-30 05:44 bootanimation
-rwxr-xr-x system   system        205 2010-07-30 05:44 monkey
-rwxr-xr-x system   system       9684 2010-07-30 05:44 flash_image
-rwxr-xr-x system   system       5648 2010-07-30 05:44 netcfg
-rwxr-xr-x system   system      35288 2010-07-30 05:44 alsa_amixer
-rwxr-xr-x system   system      77300 2010-07-30 05:44 newfs_msdos
-rwxr-xr-x system   system     151868 2010-07-30 05:44 gdbserver
-rwxr-xr-x system   system      10724 2010-07-30 05:44 showlease
-rwxr-xr-x system   system       5404 2010-07-30 05:44 schedtest
-rwxr-xr-x system   system      77300 2010-07-30 05:44 notify
-rwxr-xr-x system   system       5516 2010-07-30 05:44 qemu-props
-rwxr-xr-x system   system     210560 2010-07-30 05:44 applypatch_static
-rwxr-xr-x system   system      77300 2010-07-30 05:44 ifconfig
-rwxr-xr-x system   system      23204 2010-07-30 05:44 hciattach
-rwxr-xr-x system   system      77300 2010-07-30 05:44 chmod
-rwxr-xr-x system   system      77300 2010-07-30 05:44 chown
-rwxr-xr-x system   system      77300 2010-07-30 05:44 dmesg
-rwxr-xr-x system   system       5680 2010-07-30 05:44 app_process
-rwxr-xr-x system   system      77300 2010-07-30 05:44 setconsole
-rwxr-xr-x system   system      77300 2010-07-30 05:44 iftop
-rwxr-xr-x system   system     163144 2010-07-30 05:44 racoon
-rwxr-xr-x system   system      77300 2010-07-30 05:44 ioctl
-rw-r--r-- system   system        201 2010-07-30 05:44 input
-rwxr-xr-x system   system       5456 2010-07-30 05:44 mediaserver
-rwxr-xr-x system   system      77300 2010-07-30 05:44 lsmod
-rwxr-xr-x system   system      77300 2010-07-30 05:44 mkdir
-rwxr-xr-x system   system      77300 2010-07-30 05:44 reboot
-rwxr-xr-x system   system      77300 2010-07-30 05:44 mount
-rwxr-xr-x system   system      77300 2010-07-30 05:44 renice
-rwxr-xr-x system   system       5436 2010-07-30 05:44 system_server
-rwxr-xr-x system   system       9868 2010-07-30 05:44 servicemanager
-rwxr-xr-x system   system      13764 2010-07-30 05:44 qemud
-rwxr-xr-x system   system      77300 2010-07-30 05:44 rmdir
-rwxr-xr-x system   system      77300 2010-07-30 05:44 rmmod
-rwxr-xr-x system   system      77300 2010-07-30 05:44 route
-rwxr-xr-x system   system      77300 2010-07-30 05:44 sleep
-rwxr-xr-x system   system      77300 2010-07-30 05:44 start
-rwxr-xr-x system   system      60036 2010-07-30 05:44 alsa_ctl
-rwxr-xr-x system   system      77300 2010-07-30 05:44 sendevent
-rwxr-xr-x system   system       5556 2010-07-30 05:44 sdutil
-rwxr-xr-x system   system      62664 2010-07-30 05:44 check_prereq
-rwxr-xr-x system   system     251836 2010-07-30 05:44 updater
-rwxr-xr-x system   system       6524 2010-07-30 05:44 keystore_cli
-rwxr-xr-x system   system      39496 2010-07-30 05:44 alsa_aplay
-rwxr-xr-x system   system      77300 2010-07-30 05:44 umount
-rwxr-xr-x system   system     301592 2010-07-30 05:44 recovery
-rwxr-xr-x system   system      14292 2010-07-30 05:44 dumpcrash
-rwxr-xr-x system   system      77300 2010-07-30 05:44 vmstat
-rwxr-xr-x system   system       9744 2010-07-30 05:44 dexopt
-rwxr-xr-x system   system      44552 2010-07-30 05:44 dhcpcd
-rwxr-xr-x system   system      10028 2010-07-30 05:44 keystore
-rwxr-xr-x system   system      14292 2010-07-30 05:44 dumpstate
-rwxr-xr-x system   system       5508 2010-07-30 05:44 bugreport
-rwxr-xr-x system   system      77300 2010-07-30 05:44 printenv
-rwxr-xr-x system   system      90920 2010-07-30 05:44 applypatch
-rwxr-xr-x system   system      50616 2010-07-30 05:44 sdptool
-rwxr-xr-x system   system      77300 2010-07-30 05:44 getevent
-rwxr-xr-x system   system      14052 2010-07-30 05:44 installd
-rwxr-xr-x system   system       5448 2010-07-30 05:44 surfaceflinger
-rwxr-xr-x system   system       9864 2010-07-30 05:44 service
Just did some house cleaning on the header files,
Even after I masked the hrtimer.h or timer.h everything seem to compile perfectly, able to load, but PWM still at 21.74KHz.
I found that interrupt.h contains hrtimer.h

Code:
//#include <linux/device.h>  
//#include <linux/kthread.h>
//#include <linux/irq.h>
//#include <linux/platform_device.h>
//#include <linux/slab.h>

//#include <linux/string.h>
//#include <linux/version.h>
//#include <linux/vmalloc.h>	// vmalloc
//#include <linux/kernel.h>
//#include <linux/device.h>

//#include <linux/module.h>
//#include <linux/mutex.h>
//#include <linux/init.h>
//#include <linux/mm.h>
//#include <linux/fcntl.h>
//#include <linux/ioctl.h>
//#include <asm/io.h>

//#include <linux/hrtimer.h>	// looking for hrtimer
//#include <linux/timer.h>
//#include <linux/time.h> 
//#include <linux/delay.h>

#include <linux/fs.h>		// file operation
#include <plat/mux.h>
#include <linux/gpio.h>
#include <linux/cdev.h>		// char device
#include <asm/uaccess.h>	// copy_from and copy_to user
#include <linux/spi/spi.h>
#include <linux/interrupt.h>	// tasklet

Last edited by dennisdd; 03-04-2012 at 02:00 AM.
 
Old 03-04-2012, 06:59 AM   #17
cin_
Member
 
Registered: Dec 2010
Posts: 281

Rep: Reputation: 24
modprobe()

How are you running these tests? What is that code?
Also, just to get a feel for your code layout: which functions are your init_module() and cleanup_module() functions?


It seems that adb() echos the command call and then the standard output. Hence the ...

Code:
# /system/bin/lsmod
/system/bin/lsmod
#
I don't know the probability that this could be the case, but I suppose that could mean there are no loadable modules loaded to your kernel.
You could test it by running modprobe...
Code:
# ls /system/lib/modules/
...
ANY_RND_MODULE.ko
...
# adb shell modprobe ANY_RND_MODULE
# /system/bin/lsmod
And see if the random module you loaded appears.
Post the process here...

If the random module does appear then I would guess that the reason your lsmod() was empty was because there were no loadable modules running, and consequently that means the module you are writing was not loaded and so your tests do not reflect any changes potentially made by the unloaded module.

Last edited by cin_; 03-04-2012 at 07:56 PM. Reason: gramm`err
 
Old 03-05-2012, 06:33 AM   #18
dennisdd
Member
 
Registered: Oct 2011
Posts: 37

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by cin_ View Post
How are you running these tests? What is that code?
Also, just to get a feel for your code layout: which functions are your init_module() and cleanup_module() functions?


It seems that adb() echos the command call and then the standard output. Hence the ...

Code:
# /system/bin/lsmod
/system/bin/lsmod
#
I don't know the probability that this could be the case, but I suppose that could mean there are no loadable modules loaded to your kernel.
You could test it by running modprobe...
Code:
# ls /system/lib/modules/
...
ANY_RND_MODULE.ko
...
# adb shell modprobe ANY_RND_MODULE
# /system/bin/lsmod
And see if the random module you loaded appears.
Post the process here...

If the random module does appear then I would guess that the reason your lsmod() was empty was because there were no loadable modules running, and consequently that means the module you are writing was not loaded and so your tests do not reflect any changes potentially made by the unloaded module.
Hi cin,

I can find my device driver under $ls /dev/ .
To test if my module able to communicate with me I use echo or cat. (Yea, I didn't post everything there kinda big files other part is not related to the timer interrupt. But I believe the one I posted should be able to works.)

There is a testgpio_write function for me to echo it from adb shell.
Which will trigger the timer interrupt to lunch.

my_hrtimer_callback with printk will print out the timing on the terminal in the same time I have a scope to read the GPIO toggling Frequency.

On this debugging environment I am not doing dynamically insmod device driver it.
 
Old 03-05-2012, 07:30 AM   #19
dennisdd
Member
 
Registered: Oct 2011
Posts: 37

Original Poster
Rep: Reputation: Disabled
Actually what are other option for me to generate PWM in MHz range? What should I use?
 
Old 03-05-2012, 08:20 PM   #20
cin_
Member
 
Registered: Dec 2010
Posts: 281

Rep: Reputation: 24
pwm.h

The best help would be to clearly state what it is you want and to what end?

How do you want to change the output? It seems to me that you want the pulse width to have a resolution in a user submitted range, ie. 1ns, 10ns, 100ns...

Why do you want to change the output? To learn more about PWM control? If so, then you will have to read through some of these below and rewrite them in a constructive way. For power control purposes then you could just poach one of these libraries that would work for you in your module.

Worth noting that increasing the PWM switching frequency will reduce the PWM resolution.



Other options, or things to look at for a way forward...
pwm.h
Another pwm.h using both hrtimer.h and gpio.h
Yet another pwm.h
PWM patch
Another patch
ChibiOS pwm.h
A PWM for LEDs

Last edited by cin_; 03-05-2012 at 08:34 PM. Reason: gramm`err
 
Old 03-06-2012, 09:28 AM   #21
dennisdd
Member
 
Registered: Oct 2011
Posts: 37

Original Poster
Rep: Reputation: Disabled
I am trying out the gptimer method, with this I can get higher Hz.

I face some kernel problem on higher frequency at 50KHz -200KHz of PWM pulses.

above 200KHz: Lost the ability to communication via adb terminal. kernel stop display any warning Abvious freeze. GPIO still keep pulsing PWM.
50KHz: Kernel show a lot warning like the following , still able to talk via adb terminal. GPIO still keep pulsing PWM.

in a normal driver, from my current understanding seem like it is not recommended to generate pulses that above 50Khz?
If so what is the recommended speed?

I did something wrong in my code using gptimer?(attached below after the kernel warnings)

<kernel warning>
Code:
alarm_release: clear alarm, pending 0
binder: release 1031:1107 transaction 3878 in, still active
binder: send failed reply for transaction 3878 to 1094:1121
binder: release 1031:1110 transaction 3591 in, still active
binder: send failed reply for transaction 3591 to 1082:1082
binder: release 1031:1111 transaction 3875 in, still active
binder: send failed reply for transaction 3875 to 1094:1094
binder: release 1031:1112 transaction 3704 in, still active
binder: send failed reply for transaction 3704 to 1087:1119
binder: release proc 1031, transaction 3662, not freed
binder: release proc 1031, transaction 3665, not freed
binder: release proc 1031, transaction 3398, not freed
binder: release proc 1031, transaction 3670, not freed
binder: release proc 1031, transaction 3846, not freed
binder: release proc 1031, transaction 3870, not freed
binder: release proc 1031, transaction 3871, not freed
binder: release proc 1031, transaction 3858, not freed
binder: release proc 1031, transaction 3866, not freed
binder: release proc 1031, transaction 3867, not freed
binder: release proc 1031, transaction 3868, not freed
binder: release proc 1031, transaction 3869, not freed
binder: 1094:1094 transaction failed 29189, size 76-0
init: untracked pid 1018 exited
init: untracked pid 1087 exited
init: untracked pid 1082 exited
init: untracked pid 1094 exited
init: untracked pid 1124 exited
init: untracked pid 1132 exited
init: untracked pid 1138 exited
init: untracked pid 1144 exited
init: untracked pid 1162 exited
init: untracked pid 1168 exited
<my pwm code>
Code:
//#include <linux/device.h>  
//#include <linux/kthread.h>
//#include <linux/irq.h>
//#include <linux/platform_device.h>
//#include <linux/slab.h>

//#include <linux/string.h>
//#include <linux/version.h>
//#include <linux/vmalloc.h>	// vmalloc
//#include <linux/kernel.h>
//#include <linux/device.h>

//#include <linux/module.h>
//#include <linux/mutex.h>
//#include <linux/init.h>
//#include <linux/mm.h>
//#include <linux/fcntl.h>
//#include <linux/ioctl.h>
//#include <asm/io.h>

//#include <linux/hrtimer.h>	// looking for hrtimer
//#include <linux/timer.h>
//#include <linux/time.h> 
//#include <linux/delay.h>

#include <linux/fs.h>		// file operation
#include <plat/mux.h>
#include <linux/gpio.h>
#include <linux/cdev.h>		// char device
#include <asm/uaccess.h>	// copy_from and copy_to user
#include <linux/spi/spi.h>
#include <linux/interrupt.h>	// tasklet, also contains hrtimer.h headers
#include <plat/dmtimer.h>

#define DEBUG_KERNEL	1
#define SPI_BUFF_SIZE	16
#define USER_BUFF_SIZE	128
#define SUCCESS		0
#define ERROR		-1

#define SPI_BUS		1
#define SPI_BUS_CS1	1
#define SPI_BUS_SPEED	1000000

#define PRODUCT_ID_ADDR	0x00
#define PRODUCT_ID	0x33
#define TAP_KEY_ENABLE	0x30
#define SFR_ADDR_RD	0x44
#define SFR_ADDR_WR	0x45
#define SFR_DATA	0x46
#define PAD_TEST	0x51

#define MS_TO_NS(x)	(x * 1E6L)
#define USER_TIMER	10

#define	HIGH		1
#define	LOW		0
#define	GPIO_130_CLK	130		// Sync Clock for image dump
#define GPIO_131_TD0	131		// Test Debug 0
#define GPIO_132_TD1	132		// Test Debug 1
#define GPIO_133_TD2	133		// Test Debug 2
#define GPIO_135_TD3	135		// Test Debug 3
#define GPIO_134_SYNC	134		// Test SYNC
#define WRITE_MODE	0x80

#define DRIVER_NAME	"testgpio"


struct testgpio_control {
	struct spi_message msg;
	struct spi_transfer transfer;
	struct spi_transfer xfer[6];
	u8 *tx_buff;
	u8 *rx_buff;
};
static struct testgpio_control testgpio_ctl;

struct testgpio_dev {
	struct semaphore spi_sem;
	struct semaphore fop_sem;
	struct mutex mutex;
	dev_t devt;
	struct cdev cdev;
	struct class *class;
	struct spi_device *spi_device;
	char *user_buff;
	u8 test_data;
        struct mutex lock;
};
static struct testgpio_dev testgpio_dev;

static struct hrtimer hr_timer;
static struct omap_dm_timer *gptimer;

static unsigned long delay_in_ms;
static int my_tasklet_data;
static int counters;

void reset_sensor(void);
void setting_timer(unsigned long data, ktime_t *t);

void gptimer_stop(void);

static ssize_t testgpio_read(	struct file *filp, char __user *buff, 
				size_t count, loff_t *offp)
{
	return 0;	
}

static irqreturn_t gptimer_interrupt(int irq, void *arg)
{
	omap_dm_timer_write_status(gptimer, OMAP_TIMER_INT_OVERFLOW);

	gpio_set_value( GPIO_130_CLK, (!gpio_get_value(GPIO_130_CLK)) );// tonggle IO

	return IRQ_HANDLED;
}

void gptimer_start(u64 time)
{
	int status;

	gptimer = omap_dm_timer_request();

	if (gptimer == NULL)
	{
		printk(KERN_ERR "@testgpio_init_gptimer failed to request gptimer\n");
	}
	else
		printk(KERN_ERR "@testgpio_init_gptimer request gptimer success!\n");

	omap_dm_timer_set_source(gptimer, OMAP_TIMER_SRC_SYS_CLK);

	status = request_irq(omap_dm_timer_get_irq(gptimer), gptimer_interrupt,
					IRQF_DISABLED, "oprofile gptimer", NULL);

	if (status) {
		omap_dm_timer_free(gptimer);
		gptimer = NULL;
		printk(KERN_ERR "unable to request gptimer IRQ\n");
	}

	omap_dm_timer_set_load_start(gptimer, 1, 0xffffffff - time);

	omap_dm_timer_set_int_enable(gptimer, OMAP_TIMER_INT_OVERFLOW);

}

void gptimer_stop(void)
{
	printk(KERN_ERR "@gptimer_stop\n");
	omap_dm_timer_set_int_enable(gptimer, 0);
	printk(KERN_ERR "@gptimer_stop p1\n");
	free_irq(omap_dm_timer_get_irq(gptimer), NULL);
	printk(KERN_ERR "@gptimer_stop p2\n");
	omap_dm_timer_free(gptimer);
	printk(KERN_ERR "@gptimer_stop p3\n");
	gptimer = NULL;
}

static ssize_t testgpio_write(	struct file *file, const char __user * buffer, 
						size_t length, loff_t * offset)
{
	int		status	= 0;
	char		cmdtype[10];
	char		wrmode[10];
	u8		addval	= 0;
	u8		dataval	= 0;
	u64		timerval= 0;
	u32		time_start, time_end;

	if (!buffer) 
		return -EFAULT;

	if (*offset > 0) 
		return 0;

	printk(KERN_ALERT "@testgpio_write\n");

	sscanf(buffer,"%s %s  %hhx %hhx %llu"
			,cmdtype, wrmode, &addval, &dataval, &timerval);
	
	if(strcmp(cmdtype,"timer") == 0)
	{
		if(strcmp(wrmode,"int")==0)
		{
			gpio_set_value( GPIO_130_CLK, (!gpio_get_value(GPIO_130_CLK)) );// tonggle IO
			gptimer_start(timerval);
		}
		else if(strcmp(wrmode,"sint")==0)
		{
			gptimer_stop();
		}
	}
	status = length; // notes: somehow this need to be length else there will be looping

	return status;
}

static int testgpio_open(struct inode *inode, struct file *filp)
{	
	int	status = 0;

	printk(KERN_ALERT "@testgpio_open\n");
	if (down_interruptible(&testgpio_dev.fop_sem)) 
		return -ERESTARTSYS;

	if (!testgpio_dev.user_buff) 
	{
		testgpio_dev.user_buff = kmalloc(USER_BUFF_SIZE, GFP_KERNEL);
		if (!testgpio_dev.user_buff) 
			status = -ENOMEM;
	}	
	up(&testgpio_dev.fop_sem);

	return status;
}

static const struct file_operations testgpio_fops = {
	.owner =	THIS_MODULE,
	.read = 	testgpio_read,
	.open =		testgpio_open,
	.write =	testgpio_write,
};

static int __init testgpio_init_gptimer(void)
{
	int status;
/*
	gptimer = omap_dm_timer_request();

	if (gptimer == NULL)
	{
		printk(KERN_ERR "@testgpio_init_gptimer failed to request gptimer\n");
	}
	else
		printk(KERN_ERR "@testgpio_init_gptimer request gptimer success!\n");

	omap_dm_timer_set_source(gptimer, OMAP_TIMER_SRC_SYS_CLK);

	status = request_irq(omap_dm_timer_get_irq(gptimer), gptimer_interrupt,
					IRQF_DISABLED, "oprofile gptimer", NULL);

	if (status) {
		omap_dm_timer_free(gptimer);
		gptimer = NULL;
		printk(KERN_ERR "unable to request gptimer IRQ\n");
	}
*/
	return SUCCESS;
}

static int __init testgpio_init_GPIO(void)
{
	int status;
	
	printk(KERN_INFO "@testgpio_init_GPIO\n");

	status = omap_cfg_reg(AE2_34XX_GPIO130_OUT);
	printk(KERN_INFO "@testgpio_init_GPIO omap_cfg_reg's status %d, %d\n",
						status,AE2_34XX_GPIO130_OUT  );

	if((gpio_request(GPIO_130_CLK, "AE2_34XX_GPIO130_OUT") == 0) &&
			(gpio_direction_output(GPIO_130_CLK, HIGH)==0) )
	{
		gpio_set_value(GPIO_130_CLK, LOW); // Preset to LOW
		printk(KERN_INFO "@testgpio_init_GPIO AE2_34XX_GPIO130_OUT is good!\n");
		status =  SUCCESS;
	}
	else
		return ERROR;

	return status; //to do
}

static int __init testgpio_init_cdev(void)
{
	int error;

	printk(KERN_ALERT "@testgpio_init_cdev\n");

	testgpio_dev.devt = MKDEV(0, 0);

	error = alloc_chrdev_region(&testgpio_dev.devt, 0, 1, DRIVER_NAME);
	if (error < 0)
	{
		printk(KERN_ALERT "alloc_chrdev_region() failed: %d \n", 
								error);
		return ERROR;
	}

	cdev_init(&testgpio_dev.cdev, &testgpio_fops);
	testgpio_dev.cdev.owner = THIS_MODULE;
	
	error = cdev_add(&testgpio_dev.cdev, testgpio_dev.devt, 1);
	if (error)
	{
		printk(KERN_ALERT "cdev_add() failed: %d\n", error);
		unregister_chrdev_region(testgpio_dev.devt, 1);
		return ERROR;
	}
	return SUCCESS;
}

static int __init testgpio_init_class(void)
{
	printk(KERN_ALERT "@testgpio_init_class\n");

	testgpio_dev.class = class_create(THIS_MODULE, DRIVER_NAME);

	if (!testgpio_dev.class)
	{
		printk(KERN_ALERT "class_create() failed\n");
		return ERROR;
	}

	if (!device_create(testgpio_dev.class, NULL, testgpio_dev.devt, NULL, 	
			DRIVER_NAME)) 
	{
		printk(KERN_ALERT "device_create(..., %s) failed\n",
						DRIVER_NAME);
		class_destroy(testgpio_dev.class);
		return ERROR;
	}
	return SUCCESS;
}

static int __init testgpio_init(void)
{
	memset(&testgpio_dev, 0, sizeof(testgpio_dev));
	memset(&testgpio_ctl, 0, sizeof(testgpio_ctl));

	sema_init(&testgpio_dev.spi_sem, 1);
	sema_init(&testgpio_dev.fop_sem, 1);
	
	if (testgpio_init_cdev() < 0) 
		goto fail_1;
	
	if (testgpio_init_class() < 0)  
		goto fail_2;


	if(testgpio_init_GPIO() < 0)
		goto fail_4;

	if(testgpio_init_gptimer() < 0)
		goto fail_5;

	return SUCCESS;

fail_5:
	gpio_free(GPIO_130_CLK);
fail_4:
	device_destroy(testgpio_dev.class, testgpio_dev.devt);
	class_destroy(testgpio_dev.class);
fail_2:
	cdev_del(&testgpio_dev.cdev);
	unregister_chrdev_region(testgpio_dev.devt, 1);
fail_1:
	return ERROR;
}
module_init(testgpio_init);

static void __exit testgpio_exit(void)
{

	device_destroy(testgpio_dev.class, testgpio_dev.devt);
	class_destroy(testgpio_dev.class);

	cdev_del(&testgpio_dev.cdev);
	unregister_chrdev_region(testgpio_dev.devt, 1);

	gpio_free(GPIO_130_CLK);

	if (testgpio_dev.user_buff)
		kfree(testgpio_dev.user_buff);
}
module_exit(testgpio_exit);

MODULE_AUTHOR("Dennis Dominic");
MODULE_DESCRIPTION("testgpio module - the video driver");
MODULE_LICENSE("GPL");
MODULE_VERSION("0.1");
 
Old 05-16-2012, 04:37 AM   #22
cin_
Member
 
Registered: Dec 2010
Posts: 281

Rep: Reputation: 24
Update

Did you ever find the functionality you were looking for?
If so, how did you do it?

Last edited by cin_; 05-16-2012 at 04:38 AM. Reason: gramm`err
 
Old 05-16-2012, 10:30 PM   #23
dennisdd
Member
 
Registered: Oct 2011
Posts: 37

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by cin_ View Post
Did you ever find the functionality you were looking for?
If so, how did you do it?
Hi cin_,

thanks for helping me in the past

The whole idea of generating PWM is to identify if the driver system able to interrupts at very tight/high freq. So PWM actually serve as indicator to my scope to see if the system able to(in short I am trying to benchmark the linux driver capabilities with my ARMs). initial my newbie plan is if driver able to capture the that high freq(nanosec) interrupts, I can do with large memory dump at high freq rates.

Bitbang, and capturing interrupts from waveform signal generator(KHz->MHz) to my driver test shows that my initial idea is a bad idea. So in the end, move to hardware solution.

PS: Correct me if I am wrong, Linux kernel's PWM driver also depends on if the CPU have build in PWM hardware support, right?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration