1 /* 2 * CAN bus driver for Bosch C_CAN controller 3 * 4 * Copyright (C) 2010 ST Microelectronics 5 * Bhupesh Sharma <bhupesh.sharma@st.com> 6 * 7 * Borrowed heavily from the C_CAN driver originally written by: 8 * Copyright (C) 2007 9 * - Sascha Hauer, Marc Kleine-Budde, Pengutronix <s.hauer@pengutronix.de> 10 * - Simon Kallweit, intefo AG <simon.kallweit@intefo.ch> 11 * 12 * Bosch C_CAN controller is compliant to CAN protocol version 2.0 part A and B. 13 * Bosch C_CAN user manual can be obtained from: 14 * http://www.semiconductors.bosch.de/media/en/pdf/ipmodules_1/c_can/ 15 * users_manual_c_can.pdf 16 * 17 * This file is licensed under the terms of the GNU General Public 18 * License version 2. This program is licensed "as is" without any 19 * warranty of any kind, whether express or implied. 20 */ 21 22 #ifndef C_CAN_H 23 #define C_CAN_H 24 25 /* c_can IF registers */ 26 struct c_can_if_regs { 27 u16 com_req; 28 u16 com_mask; 29 u16 mask1; 30 u16 mask2; 31 u16 arb1; 32 u16 arb2; 33 u16 msg_cntrl; 34 u16 data[4]; 35 u16 _reserved[13]; 36 }; 37 38 /* c_can hardware registers */ 39 struct c_can_regs { 40 u16 control; 41 u16 status; 42 u16 err_cnt; 43 u16 btr; 44 u16 interrupt; 45 u16 test; 46 u16 brp_ext; 47 u16 _reserved1; 48 struct c_can_if_regs ifregs[2]; /* [0] = IF1 and [1] = IF2 */ 49 u16 _reserved2[8]; 50 u16 txrqst1; 51 u16 txrqst2; 52 u16 _reserved3[6]; 53 u16 newdat1; 54 u16 newdat2; 55 u16 _reserved4[6]; 56 u16 intpnd1; 57 u16 intpnd2; 58 u16 _reserved5[6]; 59 u16 msgval1; 60 u16 msgval2; 61 u16 _reserved6[6]; 62 }; 63 64 /* c_can private data structure */ 65 struct c_can_priv { 66 struct can_priv can; /* must be the first member */ 67 struct napi_struct napi; 68 struct net_device *dev; 69 int tx_object; 70 int current_status; 71 int last_status; 72 u16 (*read_reg) (struct c_can_priv *priv, void *reg); 73 void (*write_reg) (struct c_can_priv *priv, void *reg, u16 val); 74 struct c_can_regs __iomem *regs; 75 unsigned long irq_flags; /* for request_irq() */ 76 unsigned int tx_next; 77 unsigned int tx_echo; 78 void *priv; /* for board-specific data */ 79 u16 irqstatus; 80 }; 81 82 struct net_device *alloc_c_can_dev(void); 83 void free_c_can_dev(struct net_device *dev); 84 int register_c_can_dev(struct net_device *dev); 85 void unregister_c_can_dev(struct net_device *dev); 86 87 #endif /* C_CAN_H */ 88