make ifxmips gpio a platform device
SVN-Revision: 9922
This commit is contained in:
parent
3a97496977
commit
1fa388162b
2 changed files with 49 additions and 11 deletions
|
@ -46,6 +46,14 @@ static struct platform_device ifxmips_led[] =
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static struct platform_device ifxmips_gpio[] =
|
||||||
|
{
|
||||||
|
{
|
||||||
|
.id = 0,
|
||||||
|
.name = "ifxmips_gpio",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
int __init ifxmips_init_devices(void)
|
int __init ifxmips_init_devices(void)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -61,6 +69,7 @@ int __init ifxmips_init_devices(void)
|
||||||
/* the following devices are generic for all targets */
|
/* the following devices are generic for all targets */
|
||||||
|
|
||||||
ifxmips_devs[dev++] = ifxmips_led;
|
ifxmips_devs[dev++] = ifxmips_led;
|
||||||
|
ifxmips_devs[dev++] = ifxmips_gpio;
|
||||||
|
|
||||||
return platform_add_devices(ifxmips_devs, dev);
|
return platform_add_devices(ifxmips_devs, dev);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include <linux/workqueue.h>
|
#include <linux/workqueue.h>
|
||||||
#include <linux/skbuff.h>
|
#include <linux/skbuff.h>
|
||||||
#include <linux/netlink.h>
|
#include <linux/netlink.h>
|
||||||
|
#include <linux/platform_device.h>
|
||||||
#include <net/sock.h>
|
#include <net/sock.h>
|
||||||
#include <asm/uaccess.h>
|
#include <asm/uaccess.h>
|
||||||
#include <asm/semaphore.h>
|
#include <asm/semaphore.h>
|
||||||
|
@ -42,6 +43,8 @@
|
||||||
#define MAX_PORTS 2
|
#define MAX_PORTS 2
|
||||||
#define PINS_PER_PORT 16
|
#define PINS_PER_PORT 16
|
||||||
|
|
||||||
|
#define DRVNAME "ifxmips_gpio"
|
||||||
|
|
||||||
static unsigned int ifxmips_gpio_major = 0;
|
static unsigned int ifxmips_gpio_major = 0;
|
||||||
|
|
||||||
#ifdef CONFIG_IFXMIPS_GPIO_RST_BTN
|
#ifdef CONFIG_IFXMIPS_GPIO_RST_BTN
|
||||||
|
@ -513,23 +516,22 @@ static struct file_operations port_fops = {
|
||||||
.ioctl = ifxmips_port_ioctl
|
.ioctl = ifxmips_port_ioctl
|
||||||
};
|
};
|
||||||
|
|
||||||
int __init
|
static int
|
||||||
ifxmips_gpio_init (void)
|
ifxmips_gpio_probe (struct platform_device *dev)
|
||||||
{
|
{
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
|
||||||
sema_init (&port_sem, 1);
|
sema_init (&port_sem, 1);
|
||||||
|
|
||||||
ifxmips_gpio_major = register_chrdev(0, "ifxmips_gpio", &port_fops);
|
ifxmips_gpio_major = register_chrdev(0, DRVNAME, &port_fops);
|
||||||
if (!ifxmips_gpio_major)
|
if (!ifxmips_gpio_major)
|
||||||
{
|
{
|
||||||
printk("ifxmips-port: Error! Could not register port device. #%d\n", ifxmips_gpio_major);
|
printk(KERN_INFO DRVNAME ": Error! Could not register port device. #%d\n", ifxmips_gpio_major);
|
||||||
retval = -EINVAL;
|
retval = -EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
create_proc_read_entry("ifxmips_gpio", 0, NULL,
|
create_proc_read_entry(DRVNAME, 0, NULL, ifxmips_port_read_procmem, NULL);
|
||||||
ifxmips_port_read_procmem, NULL);
|
|
||||||
|
|
||||||
#ifdef CONFIG_IFXMIPS_GPIO_RST_BTN
|
#ifdef CONFIG_IFXMIPS_GPIO_RST_BTN
|
||||||
ifxmips_port_set_open_drain(IFXMIPS_RST_PORT, IFXMIPS_RST_PIN);
|
ifxmips_port_set_open_drain(IFXMIPS_RST_PORT, IFXMIPS_RST_PIN);
|
||||||
|
@ -545,20 +547,47 @@ ifxmips_gpio_init (void)
|
||||||
add_timer(&rst_button_timer);
|
add_timer(&rst_button_timer);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printk("registered ifxmips gpio driver\n");
|
printk(KERN_INFO DRVNAME ": device successfully initialized #%d.\n", ifxmips_gpio_major);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __exit
|
static int
|
||||||
ifxmips_gpio_exit (void)
|
ifxmips_gpio_remove (struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_IFXMIPS_GPIO_RST_BTN
|
#ifdef CONFIG_IFXMIPS_GPIO_RST_BTN
|
||||||
del_timer_sync(&rst_button_timer);
|
del_timer_sync(&rst_button_timer);
|
||||||
#endif
|
#endif
|
||||||
unregister_chrdev(ifxmips_gpio_major, "ifxmips_gpio");
|
unregister_chrdev(ifxmips_gpio_major, DRVNAME);
|
||||||
remove_proc_entry("ifxmips_gpio", NULL);
|
remove_proc_entry(DRVNAME, NULL);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct
|
||||||
|
platform_driver ifxmips_gpio_driver = {
|
||||||
|
.probe = ifxmips_gpio_probe,
|
||||||
|
.remove = ifxmips_gpio_remove,
|
||||||
|
.driver = {
|
||||||
|
.name = DRVNAME,
|
||||||
|
.owner = THIS_MODULE,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
int __init
|
||||||
|
ifxmips_gpio_init (void)
|
||||||
|
{
|
||||||
|
int ret = platform_driver_register(&ifxmips_gpio_driver);
|
||||||
|
if (ret)
|
||||||
|
printk(KERN_INFO DRVNAME ": Error registering platfom driver!");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void __exit
|
||||||
|
ifxmips_gpio_exit (void)
|
||||||
|
{
|
||||||
|
platform_driver_unregister(&ifxmips_gpio_driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
module_init(ifxmips_gpio_init);
|
module_init(ifxmips_gpio_init);
|
||||||
|
|
Loading…
Reference in a new issue