/* * slot.h * (C) 2004 Moki Matsushima * * All this is intended to be used with a ISA-like slot on the SA1100's * static memory bus. * This is included by slot.c. */ #include typedef unsigned int slot_flags_t; #define CARD_NAME_LENGTH 32 #define CNL CARD_NAME_LENGTH /* General Definition */ #ifndef SUCCESS #define SUCCESS 0 #endif #ifndef FAILURE #define FAILURE -1 #endif /* PIO signal */ typedef struct slot_signal { int sid; /* signal id */ pid_t pid; /* process id */ struct task_struct *task; /* pointer to task structure */ int is; /* mask for irq source 0 disable 1 enable */ int edge; /* active edge for each irq source 0 for negative (falling) edge 1 for positive (rising) edge */ int bedge; /* both edges, or bipolar. 0 up to the setting in variable edge. 1 does action for both negative and positive edges, discards setting in variable edge. */ /* FIXME - the edge and bedge should be merged */ } slot_signal_t; typedef union data { __u8 u8; __u16 u16; __u32 u32; __u64 u64; void *ptr; } data_t; typedef struct slot_devinfo { struct slot_devinfo *next; /* next device (pio card) */ struct slot_devinfo *prev; /* previous device */ struct slot_devinfo *next_f; /* next device in same family */ struct slot_devinfo *prev_f; /* previous device in same family */ int no; /* device number (minor number) */ unsigned int csid; /* composed sub-IDs */ unsigned int irq; /* IRQ */ unsigned long base; /* base I/O address */ unsigned int open; /* open counter */ struct file_operations *fops; /* file operations for this device */ char name[CNL]; /* card name information */ struct slot_signal sig; /* user signal setting for interrupt */ unsigned int is; /* last interrupt source */ unsigned int is_edge; /* edge of last interrupt source 0 for * negative edge 1 for positive edge */ slot_flags_t flags; data_t data; int tmp; } slot_devinfo_t; int slot_major = 0; /* PIO register */ typedef struct slot_reg { unsigned int id; /* register's id */ unsigned int value; /* register's value for read/write */ unsigned int page; unsigned int addr_size; unsigned int addr_first; unsigned int addr_second; unsigned int offset; /* register's offset */ } slot_reg_t; /* IDs of ioctl commands */ enum { SLOT_IOCTL_ID_GET_INFO, SLOT_IOCTL_ID_SET_SIG, SLOT_IOCTL_ID_READ_REG, SLOT_IOCTL_ID_WRITE_REG, SLOT_IOCTL_ID_SELECT, SLOT_IOCTL_ID_READ_EEP, SLOT_IOCTL_ID_WRITE_EEP, SLOT_IOCTL_ID_ENABLE_EEP, SLOT_IOCTL_ID_DISABLE_EEP, SLOT_IOCTL_ID_READ_SN, SLOT_IOCTL_ID_READ_MAC, SLOT_IOCTL_ID_WRITE_MAC, SLOT_IOCTL_ID_DI, SLOT_IOCTL_ID_DO, SLOT_IOCTL_ID_AI, SLOT_IOCTL_ID_AO, SLOT_IOCTL_ID_AO_PAT, SLOT_IOCTL_ID_AO_PAT_ADD, SLOT_IOCTL_ID_AO_PAT_START, SLOT_IOCTL_ID_AO_PAT_PAUSE, SLOT_IOCTL_ID_AO_PAT_STOP, SLOT_IOCTL_ID_AO_PAT_CLEAR, SLOT_IOCTL_ID_AO_PAT_STATUS, SLOT_IOCTL_ID_AO_PAT_RETRIEVE, SLOT_IOCTL_ID_KEEP_ALIVE, SLOT_IOCTL_ID_NO_KEEP_ALIVE, SLOT_IOCTL_ID_LAST }; /* SLOT IOCTL command */ #define SLOT_MAGIC_NUM 0x57 /* why? my office ID */ #define SLOT_GET_INFO _IOR(SLOT_MAGIC_NUM, SLOT_IOCTL_ID_GET_INFO, slot_devinfo_t *) #define SLOT_SET_SIG _IOR(SLOT_MAGIC_NUM, SLOT_IOCTL_ID_SET_SIG, slot_signal_t *) #define SLOT_READ_REG _IOR(SLOT_MAGIC_NUM, SLOT_IOCTL_ID_READ_REG, slot_reg_t *) #define SLOT_WRITE_REG _IOR(SLOT_MAGIC_NUM, SLOT_IOCTL_ID_WRITE_REG, slot_reg_t *) #define SLOT_SELECT _IOR(SLOT_MAGIC_NUM, SLOT_IOCTL_ID_SELECT, slot_reg_t *) #define READ_EEP _IOR(SLOT_MAGIC_NUM, SLOT_IOCTL_ID_READ_EEP, slot_reg_t *) #define WRITE_EEP _IOR(SLOT_MAGIC_NUM, SLOT_IOCTL_ID_WRITE_EEP, slot_reg_t *) #define ENABLE_EEP _IOR(SLOT_MAGIC_NUM, SLOT_IOCTL_ID_ENABLE_EEP, slot_reg_t *) #define DISABLE_EEP _IOR(SLOT_MAGIC_NUM, SLOT_IOCTL_ID_DISABLE_EEP, slot_reg_t *) #define READ_SN _IOR(SLOT_MAGIC_NUM, SLOT_IOCTL_ID_READ_SN, slot_reg_t *) #define READ_MAC _IOR(SLOT_MAGIC_NUM, SLOT_IOCTL_ID_READ_MAC, slot_reg_t *) #define WRITE_MAC _IOR(SLOT_MAGIC_NUM, SLOT_IOCTL_ID_WRITE_MAC, slot_reg_t *)