Dear sir,
I am using TMS320DM355 processor based IPNC camera and also i am having montavista 4.0.1 tool chain with dvsdk 1.20 i tried to write a gpio driver and i taken from the ti forum i tried to compiled it.It is running but after generation of .ko file it is not inserting in the board kernel.It showing some error.
The error is
unknown symbol
1.gpio_free
2.gpio_direction_output
3.gpio_direction_input
4.gpio_get_value
5.gpio_set_value
6.gpio_request
And the driver code is
/******************************************************************************
* This files declares the ioctl's that can be used to read/write GPIO pins
* from the user application.
*
* Original Author: Brijesh Singh, Texas Instruments Inc
******************************************************************************/
/* Include linux kernel header files */
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/cdev.h>
#include <asm/uaccess.h>
#include <linux/ioctl.h>
#include <asm/arch/hardware.h>
#include <asm/gpio.h>
/* Include local header file */
#include "user_gpio.h"
MODULE_LICENSE("GPL");
/* declare location variables */
static dev_t dev;
static struct cdev *user_gpio_cdev;
/* declare local functions */
static int user_gpio_open (struct inode *inode, struct file *filp);
static int user_gpio_release (struct inode *inode, struct file *filp);
static int user_gpio_ioctl (struct inode *inode, struct file *flip,
unsigned int cmd, unsigned long args);
static int user_gpio_get_value(int num);
static int user_gpio_set_value(int num, int val);
int user_gpio_init_module(void);
void user_gpio_cleanup_module(void);
/* declare file operation structure */
static struct file_operations user_gpio_fops = {
.owner = THIS_MODULE,
.open = user_gpio_open,
.ioctl = user_gpio_ioctl,
.release = user_gpio_release,
};
/******************************************************************************
* user_gpio_get_value - This function returns the value of gpio pin number.
*****************************************************************************/
static int user_gpio_get_value (int num)
{
int status, val;
/* first request the gpio pin */
status = gpio_request(num, "user_gpio");
if (status < 0) {
printk(KERN_DEBUG "Failed to request GPIO%d\n", num);
return -1;
}
/* set the direction as input */
gpio_direction_input(num);
/* get the value */
val = gpio_get_value(num);
/* free gpio resources */
gpio_free(num);
return val;
}
/******************************************************************************
* user_gpio_set_value - This function sets the value of gpio pin number.
*****************************************************************************/
static int user_gpio_set_value (int num, int val)
{
int status;
/* first request the gpio pin */
status = gpio_request(num, "user_gpio");
if (status < 0) {
printk(KERN_DEBUG "Failed to request GPIO%d\n", num);
return -1;
}
/* set the direction as output */
gpio_direction_output(num, 1);
/* set the value */
gpio_set_value(num, val);
/* free the resources */
gpio_free(num);
return 0;
}
/******************************************************************************
* user_gpio_ioctl - function to implement the GPIO ioctl's
*****************************************************************************/
static int user_gpio_ioctl (struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long args)
{
void __user *argp = (void __user *) args;
struct user_gpio gpio;
if (_IOC_TYPE(cmd) != USER_GPIO_MAGIC) {
return -ENOTTY;
}
if (_IOC_NR(cmd) > USER_GPIO_MAXNR) {
return -ENOTTY;
}
switch (cmd) {
case USER_GPIO_READ:
if (copy_from_user(&gpio, argp, sizeof(struct user_gpio)))
return -EFAULT;
gpio.value = user_gpio_get_value(gpio.num);
if (copy_to_user(argp, &gpio, sizeof(struct user_gpio)))
return -EFAULT;
break;
case USER_GPIO_WRITE:
if (copy_from_user(&gpio, argp, sizeof(struct user_gpio)))
return -EFAULT;
user_gpio_set_value(gpio.num, gpio.value);
break;
default:
return -ENOTTY;
break;
}
return 0;
}
/******************************************************************************
* user_gpio_open - do nothing
*****************************************************************************/
static int user_gpio_open (struct inode *inode, struct file *filp)
{
return 0;
}
/******************************************************************************
* user_gpio_release - do nothing
*****************************************************************************/
static int user_gpio_release (struct inode *inode, struct file *filp)
{
return 0;
}
/*****************************************************************************
* user_gpio_init_module - initialise user gpio module
****************************************************************************/
int user_gpio_init_module ()
{
if (alloc_chrdev_region(&dev, 0, 1, "user_gpio") < 0) {
printk(KERN_DEBUG "Failed to register the device\n");
return 1;
}
user_gpio_cdev = cdev_alloc();
if (user_gpio_cdev == NULL) {
printk(KERN_DEBUG "Failed to allocate cdev\n");
return 1;
}
cdev_init(user_gpio_cdev, &user_gpio_fops);
if (cdev_add(user_gpio_cdev, dev, 1) < 0) {
printk(KERN_DEBUG "Failed to add cdev\n");
return 1;
}
return 0;
}
/*****************************************************************************
* user_gpio_init_cleanup - cleanup user gpio module
****************************************************************************/
void user_gpio_cleanup_module ()
{
cdev_del(user_gpio_cdev);
unregister_chrdev_region(dev, 1);
}
/* Register driver to the kernel */
module_init(user_gpio_init_module);
module_exit(user_gpio_cleanup_module);
If any one helps to solve this problem it will be very useful for me.
Thanks