#include <linux/module.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/ioport.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/string.h>
#include <linux/poll.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/spinlock.h>
#include <asm/etraxgpio.h>
#include <asm/arch/hwregs/reg_map.h>
#include <asm/arch/hwregs/reg_rdwr.h>
#include <asm/arch/hwregs/gio_defs.h>
#include <asm/arch/hwregs/intr_vect_defs.h>
#include <asm/io.h>
#include <asm/system.h>
#include <asm/irq.h>
Include dependency graph for gpio.c:
Go to the source code of this file.
Data Structures | |
struct | gpio_private |
Defines | |
#define | GPIO_MAJOR 120 |
#define | D(x) |
#define | DP(x) |
#define | NUM_PORTS (GPIO_MINOR_LAST+1) |
#define | GIO_REG_RD_ADDR(reg) (volatile unsigned long*) (regi_gio + REG_RD_ADDR_gio_##reg ) |
#define | GIO_REG_WR_ADDR(reg) (volatile unsigned long*) (regi_gio + REG_RD_ADDR_gio_##reg ) |
Functions | |
static int | gpio_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) |
static ssize_t | gpio_write (struct file *file, const char *buf, size_t count, loff_t *off) |
static int | gpio_open (struct inode *inode, struct file *filp) |
static int | gpio_release (struct inode *inode, struct file *filp) |
static unsigned int | gpio_poll (struct file *filp, struct poll_table_struct *wait) |
static | DEFINE_SPINLOCK (alarm_lock) |
static unsigned int | gpio_poll (struct file *file, poll_table *wait) |
int | etrax_gpio_wake_up_check (void) |
static irqreturn_t | gpio_poll_timer_interrupt (int irq, void *dev_id) |
static irqreturn_t | gpio_pa_interrupt (int irq, void *dev_id) |
unsigned long | setget_input (struct gpio_private *priv, unsigned long arg) |
unsigned long | setget_output (struct gpio_private *priv, unsigned long arg) |
static int | gpio_leds_ioctl (unsigned int cmd, unsigned long arg) |
static __init int | gpio_init (void) |
module_init (gpio_init) | |
Variables | |
static char | gpio_name [] = "etrax gpio" |
static struct gpio_private * | alarmlist = 0 |
static int | gpio_some_alarms = 0 |
static unsigned long | gpio_pa_high_alarms = 0 |
static unsigned long | gpio_pa_low_alarms = 0 |
unsigned long | led_dummy |
static volatile unsigned long * | data_out [NUM_PORTS] |
static volatile unsigned long * | data_in [NUM_PORTS] |
static unsigned long | changeable_dir [NUM_PORTS] |
static unsigned long | changeable_bits [NUM_PORTS] |
static volatile unsigned long * | dir_oe [NUM_PORTS] |
file_operations | gpio_fops |
#define DP | ( | x | ) |
#define GIO_REG_RD_ADDR | ( | reg | ) | (volatile unsigned long*) (regi_gio + REG_RD_ADDR_gio_##reg ) |
#define GIO_REG_WR_ADDR | ( | reg | ) | (volatile unsigned long*) (regi_gio + REG_RD_ADDR_gio_##reg ) |
#define GPIO_MAJOR 120 |
static DEFINE_SPINLOCK | ( | alarm_lock | ) | [static] |
int etrax_gpio_wake_up_check | ( | void | ) |
Definition at line 267 of file gpio.c.
References gpio_private::alarm_wq, alarmlist, data, data_in, DP, flags, gpio_private::highalarm, gpio_private::lowalarm, gpio_private::minor, gpio_private::next, and printk.
Referenced by gpio_pa_interrupt(), and gpio_poll_timer_interrupt().
static __init int gpio_init | ( | void | ) | [static] |
Definition at line 952 of file gpio.c.
References alarmlist, GPIO_MAJOR, gpio_name, gpio_pa_interrupt(), gpio_poll_timer_interrupt(), KERN_ERR, and printk.
static int gpio_ioctl | ( | struct inode * | inode, | |
struct file * | file, | |||
unsigned int | cmd, | |||
unsigned long | arg | |||
) | [static] |
Definition at line 582 of file gpio.c.
References changeable_bits, gpio_private::clk_mask, data_in, gpio_private::data_mask, data_out, dir_oe, flags, gpio_leds_ioctl(), gpio_pa_high_alarms, gpio_pa_low_alarms, gpio_some_alarms, gpio_private::highalarm, local_irq_restore, local_irq_save, gpio_private::lowalarm, gpio_private::minor, setget_input(), setget_output(), and gpio_private::write_msb.
static int gpio_leds_ioctl | ( | unsigned int | cmd, | |
unsigned long | arg | |||
) | [static] |
Definition at line 859 of file gpio.c.
References green, LED_ACTIVE_SET_G, LED_ACTIVE_SET_R, and red.
Referenced by gpio_ioctl().
static int gpio_open | ( | struct inode * | inode, | |
struct file * | filp | |||
) | [static] |
Definition at line 439 of file gpio.c.
References alarmlist, GFP_KERNEL, init_waitqueue_head, kmalloc, and memset().
static irqreturn_t gpio_pa_interrupt | ( | int | irq, | |
void * | dev_id | |||
) | [static] |
Definition at line 311 of file gpio.c.
References etrax_gpio_wake_up_check(), gpio_pa_high_alarms, gpio_pa_low_alarms, gpio_some_alarms, spin_lock, and spin_unlock.
Referenced by gpio_init().
static unsigned int gpio_poll | ( | struct file * | file, | |
poll_table * | wait | |||
) | [static] |
Definition at line 178 of file gpio.c.
References gpio_private::alarm_wq, data, data_in, DP, flags, gpio_private::highalarm, local_irq_restore, local_irq_save, gpio_private::lowalarm, mask, gpio_private::minor, and printk.
static unsigned int gpio_poll | ( | struct file * | filp, | |
struct poll_table_struct * | wait | |||
) | [static] |
static irqreturn_t gpio_poll_timer_interrupt | ( | int | irq, | |
void * | dev_id | |||
) | [static] |
Definition at line 302 of file gpio.c.
References etrax_gpio_wake_up_check(), and gpio_some_alarms.
Referenced by gpio_init().
static int gpio_release | ( | struct inode * | inode, | |
struct file * | filp | |||
) | [static] |
Definition at line 476 of file gpio.c.
References alarmlist, gpio_pa_high_alarms, gpio_pa_low_alarms, gpio_some_alarms, gpio_private::highalarm, kfree, gpio_private::lowalarm, gpio_private::minor, and gpio_private::next.
static ssize_t gpio_write | ( | struct file * | file, | |
const char * | buf, | |||
size_t | count, | |||
loff_t * | off | |||
) | [static] |
Definition at line 368 of file gpio.c.
References gpio_private::clk_mask, D, data, gpio_private::data_mask, data_out, flags, local_irq_restore, local_irq_save, gpio_private::minor, printk, and gpio_private::write_msb.
module_init | ( | gpio_init | ) |
unsigned long setget_input | ( | struct gpio_private * | priv, | |
unsigned long | arg | |||
) | [inline] |
Definition at line 539 of file gpio.c.
References changeable_dir, dir_oe, flags, local_irq_restore, local_irq_save, and gpio_private::minor.
Referenced by gpio_ioctl().
unsigned long setget_output | ( | struct gpio_private * | priv, | |
unsigned long | arg | |||
) | [inline] |
Definition at line 565 of file gpio.c.
References changeable_dir, dir_oe, flags, local_irq_restore, local_irq_save, and gpio_private::minor.
Referenced by gpio_ioctl().
struct gpio_private* alarmlist = 0 [static] |
Definition at line 97 of file gpio.c.
Referenced by etrax_gpio_wake_up_check(), gpio_init(), gpio_open(), and gpio_release().
unsigned long changeable_bits[NUM_PORTS] [static] |
Initial value:
{ CONFIG_ETRAX_PA_CHANGEABLE_BITS, CONFIG_ETRAX_PB_CHANGEABLE_BITS, 0, CONFIG_ETRAX_PC_CHANGEABLE_BITS, CONFIG_ETRAX_PD_CHANGEABLE_BITS, CONFIG_ETRAX_PE_CHANGEABLE_BITS, }
Definition at line 151 of file gpio.c.
Referenced by gpio_ioctl().
unsigned long changeable_dir[NUM_PORTS] [static] |
Initial value:
{ CONFIG_ETRAX_PA_CHANGEABLE_DIR, CONFIG_ETRAX_PB_CHANGEABLE_DIR, 0, CONFIG_ETRAX_PC_CHANGEABLE_DIR, CONFIG_ETRAX_PD_CHANGEABLE_DIR, CONFIG_ETRAX_PE_CHANGEABLE_DIR, }
Definition at line 139 of file gpio.c.
Referenced by setget_input(), and setget_output().
volatile unsigned long* data_in[NUM_PORTS] [static] |
Initial value:
{ GIO_REG_RD_ADDR(r_pa_din), GIO_REG_RD_ADDR(r_pb_din), &led_dummy, GIO_REG_RD_ADDR(r_pc_din), GIO_REG_RD_ADDR(r_pd_din), GIO_REG_RD_ADDR(r_pe_din), }
Definition at line 127 of file gpio.c.
Referenced by etrax_gpio_wake_up_check(), finish_data(), gpio_ioctl(), gpio_poll(), and toggle_led().
volatile unsigned long* data_out[NUM_PORTS] [static] |
Initial value:
{ GIO_REG_WR_ADDR(rw_pa_dout), GIO_REG_WR_ADDR(rw_pb_dout), &led_dummy, GIO_REG_WR_ADDR(rw_pc_dout), GIO_REG_WR_ADDR(rw_pd_dout), GIO_REG_WR_ADDR(rw_pe_dout), }
Definition at line 115 of file gpio.c.
Referenced by gpio_ioctl(), gpio_write(), and toggle_led().
volatile unsigned long* dir_oe[NUM_PORTS] [static] |
Initial value:
{ GIO_REG_WR_ADDR(rw_pa_oe), GIO_REG_WR_ADDR(rw_pb_oe), &led_dummy, GIO_REG_WR_ADDR(rw_pc_oe), GIO_REG_WR_ADDR(rw_pd_oe), GIO_REG_WR_ADDR(rw_pe_oe), }
Definition at line 163 of file gpio.c.
Referenced by gpio_ioctl(), setget_input(), and setget_output().
struct file_operations gpio_fops |
Initial value:
{ .owner = THIS_MODULE, .poll = gpio_poll, .ioctl = gpio_ioctl, .write = gpio_write, .open = gpio_open, .release = gpio_release, }
char gpio_name[] = "etrax gpio" [static] |
unsigned long gpio_pa_high_alarms = 0 [static] |
Definition at line 100 of file gpio.c.
Referenced by gpio_ioctl(), gpio_pa_interrupt(), and gpio_release().
unsigned long gpio_pa_low_alarms = 0 [static] |
Definition at line 101 of file gpio.c.
Referenced by gpio_ioctl(), gpio_pa_interrupt(), and gpio_release().
int gpio_some_alarms = 0 [static] |
Definition at line 99 of file gpio.c.
Referenced by gpio_ioctl(), gpio_pa_interrupt(), gpio_poll_timer_interrupt(), and gpio_release().