/* * jcan.h -- header for the CAN driver * * Copyright (C) 2003 George Cewe * Copyright (C) 2003 Advanced Concepts Inc. * Copyright (C) 2002 Alessandro Rubini * Copyright (C) 2001 Ascensit S.p.A * Author: Rodolfo Giometti * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __JCAN_H__ #define __JCAN_H__ #include #define CAN_READ_BUFS 64 /* read buffer has 64 messages */ #define I527_XTD_XTD 0x04 #define I527_XTD_STD 0x00 /* * data structures used in both kernel and user space (mostly for ioctl) */ typedef enum { B_100K ,B_125K ,B_250K ,B_500K ,B_1M ,BPS_MAX } BPS; typedef struct { __u8 reg; __u8 val; } CAN_REG; #define CAN_MULTIREG_MAX 16 typedef struct { __u8 first, last; __u8 regs[CAN_MULTIREG_MAX]; } CAN_MULTIREG; typedef struct { __u8 data[256]; } CAN_ALLREGS; typedef struct { __u32 m_msg15; __u32 m_xtd; __u16 m_std; } CAN_MASKS; /* This structure is both part of the device structure and arg of ioctl */ typedef struct { __u32 id; __u8 msgobj; /* 1..15 */ __u8 flags; __u8 config; /* same as config register */ __u8 dlc; /* data length counter */ __u8 data[8]; __u16 error; /* also for alignment */ } CAN_MSG; /* And these are the message flags */ #define CAN_MSGFLAG_WRITE 0x01 #define CAN_MSGFLAG_READ 0x02 /* set either write read */ #define CAN_MSGFLAG_DOREMOTE 0x04 /* send a remote frame, for reading */ #define CAN_MSGFLAG_PEEKONLY 0x08 /* used by IOCPEEK */ #define CAN_ERROR_MASK 0x07 /* Tx error code */ #define CAN_ERROR_MSGLST 0x10 /* Message lost error */ #define CAN_ERROR_OVRFLW 0x80 /* Read buffer overflow */ /* * ioctl() definitons */ /* Use 'z' as magic number */ #define CAN_IOC_MAGIC 'z' /* like other CAN drivers, per ioctl-number.txt */ #define CAN_IOCRESET _IO(CAN_IOC_MAGIC, 0) /* individual registers */ #define CAN_IOCREADREG _IOWR(CAN_IOC_MAGIC, 1, CAN_REG) #define CAN_IOCWRITEREG _IOW(CAN_IOC_MAGIC, 2, CAN_REG) /* range of registers */ #define CAN_IOCREADMULTI _IOWR(CAN_IOC_MAGIC, 3, CAN_MULTIREG) #define CAN_IOCWRITEMULTI _IOW(CAN_IOC_MAGIC, 4, CAN_MULTIREG) /* one message */ #define CAN_IOCSETUPMSG _IOW(CAN_IOC_MAGIC, 5, CAN_MSG) #define CAN_IOCWRITEMSG _IOW(CAN_IOC_MAGIC, 6, CAN_MSG) #define CAN_IOCTXMSG _IOW(CAN_IOC_MAGIC, 7, unsigned long) #define CAN_IOCRXMSG _IOWR(CAN_IOC_MAGIC, 8, CAN_MSG) #define CAN_IOCRELEASEMSG _IOW(CAN_IOC_MAGIC, 9, unsigned long) /* all registers */ #define CAN_IOCREADALL _IOR(CAN_IOC_MAGIC, 10, CAN_ALLREGS) /* masks, times, bus configuration */ #define CAN_IOCGETMASKS _IOR(CAN_IOC_MAGIC, 11, CAN_MASKS) #define CAN_IOCSETMASKS _IOW(CAN_IOC_MAGIC, 12, CAN_MASKS) #define CAN_IOCGETBPS _IOR(CAN_IOC_MAGIC, 13, unsigned long) #define CAN_IOCSETBPS _IOW(CAN_IOC_MAGIC, 14, unsigned long) #define CAN_IOCGETBUSCONF _IOR(CAN_IOC_MAGIC, 15, CAN_REG) #define CAN_IOCSETBUSCONF _IOW(CAN_IOC_MAGIC, 16, CAN_REG) /* misc */ #define CAN_IOCSOFTRESET _IO(CAN_IOC_MAGIC, 17) #define CAN_IOCWRITEQ _IOW(CAN_IOC_MAGIC, 18, CAN_MSG) #define CAN_IOCGIRQCOUNT _IOR(CAN_IOC_MAGIC, 19, unsigned long) #define CAN_IOCREQSIGNAL _IOW(CAN_IOC_MAGIC, 20, unsigned long) /* I/O ports */ #define CAN_IOCINPUT _IOWR(CAN_IOC_MAGIC, 21, CAN_REG) #define CAN_IOCOUTPUT _IOW(CAN_IOC_MAGIC, 22, CAN_REG) #define CAN_IOCIOCFG _IOW(CAN_IOC_MAGIC, 23, CAN_REG) /* peek (like rx) */ #define CAN_IOCPEEKMSG _IOWR(CAN_IOC_MAGIC, 24, CAN_MSG) #define CAN_IOC_MAXNR 24 #endif /* __JCAN_H__ */