Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Enumerations | Functions
c_can.c File Reference
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/netdevice.h>
#include <linux/if_arp.h>
#include <linux/if_ether.h>
#include <linux/list.h>
#include <linux/io.h>
#include <linux/pm_runtime.h>
#include <linux/can.h>
#include <linux/can/dev.h>
#include <linux/can/error.h>
#include "c_can.h"

Go to the source code of this file.

Macros

#define IF_ENUM_REG_LEN   11
 
#define C_CAN_IFACE(reg, iface)   (C_CAN_IF1_##reg + (iface) * IF_ENUM_REG_LEN)
 
#define CONTROL_EX_PDR   BIT(8)
 
#define CONTROL_TEST   BIT(7)
 
#define CONTROL_CCE   BIT(6)
 
#define CONTROL_DISABLE_AR   BIT(5)
 
#define CONTROL_ENABLE_AR   (0 << 5)
 
#define CONTROL_EIE   BIT(3)
 
#define CONTROL_SIE   BIT(2)
 
#define CONTROL_IE   BIT(1)
 
#define CONTROL_INIT   BIT(0)
 
#define TEST_RX   BIT(7)
 
#define TEST_TX1   BIT(6)
 
#define TEST_TX2   BIT(5)
 
#define TEST_LBACK   BIT(4)
 
#define TEST_SILENT   BIT(3)
 
#define TEST_BASIC   BIT(2)
 
#define STATUS_PDA   BIT(10)
 
#define STATUS_BOFF   BIT(7)
 
#define STATUS_EWARN   BIT(6)
 
#define STATUS_EPASS   BIT(5)
 
#define STATUS_RXOK   BIT(4)
 
#define STATUS_TXOK   BIT(3)
 
#define ERR_CNT_TEC_MASK   0xff
 
#define ERR_CNT_TEC_SHIFT   0
 
#define ERR_CNT_REC_SHIFT   8
 
#define ERR_CNT_REC_MASK   (0x7f << ERR_CNT_REC_SHIFT)
 
#define ERR_CNT_RP_SHIFT   15
 
#define ERR_CNT_RP_MASK   (0x1 << ERR_CNT_RP_SHIFT)
 
#define BTR_BRP_MASK   0x3f
 
#define BTR_BRP_SHIFT   0
 
#define BTR_SJW_SHIFT   6
 
#define BTR_SJW_MASK   (0x3 << BTR_SJW_SHIFT)
 
#define BTR_TSEG1_SHIFT   8
 
#define BTR_TSEG1_MASK   (0xf << BTR_TSEG1_SHIFT)
 
#define BTR_TSEG2_SHIFT   12
 
#define BTR_TSEG2_MASK   (0x7 << BTR_TSEG2_SHIFT)
 
#define BRP_EXT_BRPE_MASK   0x0f
 
#define BRP_EXT_BRPE_SHIFT   0
 
#define IF_COMR_BUSY   BIT(15)
 
#define IF_COMM_WR   BIT(7)
 
#define IF_COMM_MASK   BIT(6)
 
#define IF_COMM_ARB   BIT(5)
 
#define IF_COMM_CONTROL   BIT(4)
 
#define IF_COMM_CLR_INT_PND   BIT(3)
 
#define IF_COMM_TXRQST   BIT(2)
 
#define IF_COMM_DATAA   BIT(1)
 
#define IF_COMM_DATAB   BIT(0)
 
#define IF_COMM_ALL
 
#define IF_ARB_MSGVAL   BIT(15)
 
#define IF_ARB_MSGXTD   BIT(14)
 
#define IF_ARB_TRANSMIT   BIT(13)
 
#define IF_MCONT_NEWDAT   BIT(15)
 
#define IF_MCONT_MSGLST   BIT(14)
 
#define IF_MCONT_CLR_MSGLST   (0 << 14)
 
#define IF_MCONT_INTPND   BIT(13)
 
#define IF_MCONT_UMASK   BIT(12)
 
#define IF_MCONT_TXIE   BIT(11)
 
#define IF_MCONT_RXIE   BIT(10)
 
#define IF_MCONT_RMTEN   BIT(9)
 
#define IF_MCONT_TXRQST   BIT(8)
 
#define IF_MCONT_EOB   BIT(7)
 
#define IF_MCONT_DLC_MASK   0xf
 
#define IFX_WRITE_LOW_16BIT(x)   ((x) & 0xFFFF)
 
#define IFX_WRITE_HIGH_16BIT(x)   (((x) & 0xFFFF0000) >> 16)
 
#define C_CAN_NO_OF_OBJECTS   32
 
#define C_CAN_MSG_OBJ_RX_NUM   16
 
#define C_CAN_MSG_OBJ_TX_NUM   16
 
#define C_CAN_MSG_OBJ_RX_FIRST   1
 
#define C_CAN_MSG_OBJ_RX_LAST
 
#define C_CAN_MSG_OBJ_TX_FIRST   (C_CAN_MSG_OBJ_RX_LAST + 1)
 
#define C_CAN_MSG_OBJ_TX_LAST
 
#define C_CAN_MSG_OBJ_RX_SPLIT   9
 
#define C_CAN_MSG_RX_LOW_LAST   (C_CAN_MSG_OBJ_RX_SPLIT - 1)
 
#define C_CAN_NEXT_MSG_OBJ_MASK   (C_CAN_MSG_OBJ_TX_NUM - 1)
 
#define RECEIVE_OBJECT_BITS   0x0000ffff
 
#define STATUS_INTERRUPT   0x8000
 
#define ENABLE_ALL_INTERRUPTS   1
 
#define DISABLE_ALL_INTERRUPTS   0
 
#define MIN_TIMEOUT_VALUE   6
 
#define INIT_WAIT_MS   1000
 
#define C_CAN_NAPI_WEIGHT   C_CAN_MSG_OBJ_RX_NUM
 

Enumerations

enum  c_can_lec_type {
  LEC_NO_ERROR = 0, LEC_STUFF_ERROR, LEC_FORM_ERROR, LEC_ACK_ERROR,
  LEC_BIT1_ERROR, LEC_BIT0_ERROR, LEC_CRC_ERROR, LEC_UNUSED
}
 
enum  c_can_bus_error_types { C_CAN_NO_ERROR = 0, C_CAN_BUS_OFF, C_CAN_ERROR_WARNING, C_CAN_ERROR_PASSIVE }
 

Functions

struct net_devicealloc_c_can_dev (void)
 
 EXPORT_SYMBOL_GPL (alloc_c_can_dev)
 
void free_c_can_dev (struct net_device *dev)
 
 EXPORT_SYMBOL_GPL (free_c_can_dev)
 
int register_c_can_dev (struct net_device *dev)
 
 EXPORT_SYMBOL_GPL (register_c_can_dev)
 
void unregister_c_can_dev (struct net_device *dev)
 
 EXPORT_SYMBOL_GPL (unregister_c_can_dev)
 
 MODULE_AUTHOR ("Bhupesh Sharma <[email protected]>")
 
 MODULE_LICENSE ("GPL v2")
 
 MODULE_DESCRIPTION ("CAN bus driver for Bosch C_CAN controller")
 

Macro Definition Documentation

#define BRP_EXT_BRPE_MASK   0x0f

Definition at line 97 of file c_can.c.

#define BRP_EXT_BRPE_SHIFT   0

Definition at line 98 of file c_can.c.

#define BTR_BRP_MASK   0x3f

Definition at line 87 of file c_can.c.

#define BTR_BRP_SHIFT   0

Definition at line 88 of file c_can.c.

#define BTR_SJW_MASK   (0x3 << BTR_SJW_SHIFT)

Definition at line 90 of file c_can.c.

#define BTR_SJW_SHIFT   6

Definition at line 89 of file c_can.c.

#define BTR_TSEG1_MASK   (0xf << BTR_TSEG1_SHIFT)

Definition at line 92 of file c_can.c.

#define BTR_TSEG1_SHIFT   8

Definition at line 91 of file c_can.c.

#define BTR_TSEG2_MASK   (0x7 << BTR_TSEG2_SHIFT)

Definition at line 94 of file c_can.c.

#define BTR_TSEG2_SHIFT   12

Definition at line 93 of file c_can.c.

#define C_CAN_IFACE (   reg,
  iface 
)    (C_CAN_IF1_##reg + (iface) * IF_ENUM_REG_LEN)

Definition at line 47 of file c_can.c.

#define C_CAN_MSG_OBJ_RX_FIRST   1

Definition at line 147 of file c_can.c.

#define C_CAN_MSG_OBJ_RX_LAST
Value:
C_CAN_MSG_OBJ_RX_NUM - 1)

Definition at line 148 of file c_can.c.

#define C_CAN_MSG_OBJ_RX_NUM   16

Definition at line 144 of file c_can.c.

#define C_CAN_MSG_OBJ_RX_SPLIT   9

Definition at line 155 of file c_can.c.

#define C_CAN_MSG_OBJ_TX_FIRST   (C_CAN_MSG_OBJ_RX_LAST + 1)

Definition at line 151 of file c_can.c.

#define C_CAN_MSG_OBJ_TX_LAST
Value:
C_CAN_MSG_OBJ_TX_NUM - 1)

Definition at line 152 of file c_can.c.

#define C_CAN_MSG_OBJ_TX_NUM   16

Definition at line 145 of file c_can.c.

#define C_CAN_MSG_RX_LOW_LAST   (C_CAN_MSG_OBJ_RX_SPLIT - 1)

Definition at line 156 of file c_can.c.

#define C_CAN_NAPI_WEIGHT   C_CAN_MSG_OBJ_RX_NUM

Definition at line 175 of file c_can.c.

#define C_CAN_NEXT_MSG_OBJ_MASK   (C_CAN_MSG_OBJ_TX_NUM - 1)

Definition at line 158 of file c_can.c.

#define C_CAN_NO_OF_OBJECTS   32

Definition at line 143 of file c_can.c.

#define CONTROL_CCE   BIT(6)

Definition at line 54 of file c_can.c.

#define CONTROL_DISABLE_AR   BIT(5)

Definition at line 55 of file c_can.c.

#define CONTROL_EIE   BIT(3)

Definition at line 57 of file c_can.c.

#define CONTROL_ENABLE_AR   (0 << 5)

Definition at line 56 of file c_can.c.

#define CONTROL_EX_PDR   BIT(8)

Definition at line 50 of file c_can.c.

#define CONTROL_IE   BIT(1)

Definition at line 59 of file c_can.c.

#define CONTROL_INIT   BIT(0)

Definition at line 60 of file c_can.c.

#define CONTROL_SIE   BIT(2)

Definition at line 58 of file c_can.c.

#define CONTROL_TEST   BIT(7)

Definition at line 53 of file c_can.c.

#define DISABLE_ALL_INTERRUPTS   0

Definition at line 166 of file c_can.c.

#define ENABLE_ALL_INTERRUPTS   1

Definition at line 165 of file c_can.c.

#define ERR_CNT_REC_MASK   (0x7f << ERR_CNT_REC_SHIFT)

Definition at line 82 of file c_can.c.

#define ERR_CNT_REC_SHIFT   8

Definition at line 81 of file c_can.c.

#define ERR_CNT_RP_MASK   (0x1 << ERR_CNT_RP_SHIFT)

Definition at line 84 of file c_can.c.

#define ERR_CNT_RP_SHIFT   15

Definition at line 83 of file c_can.c.

#define ERR_CNT_TEC_MASK   0xff

Definition at line 79 of file c_can.c.

#define ERR_CNT_TEC_SHIFT   0

Definition at line 80 of file c_can.c.

#define IF_ARB_MSGVAL   BIT(15)

Definition at line 117 of file c_can.c.

#define IF_ARB_MSGXTD   BIT(14)

Definition at line 118 of file c_can.c.

#define IF_ARB_TRANSMIT   BIT(13)

Definition at line 119 of file c_can.c.

#define IF_COMM_ALL
Value:
IF_COMM_CONTROL | IF_COMM_TXRQST | \
IF_COMM_DATAA | IF_COMM_DATAB)

Definition at line 112 of file c_can.c.

#define IF_COMM_ARB   BIT(5)

Definition at line 106 of file c_can.c.

#define IF_COMM_CLR_INT_PND   BIT(3)

Definition at line 108 of file c_can.c.

#define IF_COMM_CONTROL   BIT(4)

Definition at line 107 of file c_can.c.

#define IF_COMM_DATAA   BIT(1)

Definition at line 110 of file c_can.c.

#define IF_COMM_DATAB   BIT(0)

Definition at line 111 of file c_can.c.

#define IF_COMM_MASK   BIT(6)

Definition at line 105 of file c_can.c.

#define IF_COMM_TXRQST   BIT(2)

Definition at line 109 of file c_can.c.

#define IF_COMM_WR   BIT(7)

Definition at line 104 of file c_can.c.

#define IF_COMR_BUSY   BIT(15)

Definition at line 101 of file c_can.c.

#define IF_ENUM_REG_LEN   11

Definition at line 46 of file c_can.c.

#define IF_MCONT_CLR_MSGLST   (0 << 14)

Definition at line 124 of file c_can.c.

#define IF_MCONT_DLC_MASK   0xf

Definition at line 132 of file c_can.c.

#define IF_MCONT_EOB   BIT(7)

Definition at line 131 of file c_can.c.

#define IF_MCONT_INTPND   BIT(13)

Definition at line 125 of file c_can.c.

#define IF_MCONT_MSGLST   BIT(14)

Definition at line 123 of file c_can.c.

#define IF_MCONT_NEWDAT   BIT(15)

Definition at line 122 of file c_can.c.

#define IF_MCONT_RMTEN   BIT(9)

Definition at line 129 of file c_can.c.

#define IF_MCONT_RXIE   BIT(10)

Definition at line 128 of file c_can.c.

#define IF_MCONT_TXIE   BIT(11)

Definition at line 127 of file c_can.c.

#define IF_MCONT_TXRQST   BIT(8)

Definition at line 130 of file c_can.c.

#define IF_MCONT_UMASK   BIT(12)

Definition at line 126 of file c_can.c.

#define IFX_WRITE_HIGH_16BIT (   x)    (((x) & 0xFFFF0000) >> 16)

Definition at line 140 of file c_can.c.

#define IFX_WRITE_LOW_16BIT (   x)    ((x) & 0xFFFF)

Definition at line 139 of file c_can.c.

#define INIT_WAIT_MS   1000

Definition at line 172 of file c_can.c.

#define MIN_TIMEOUT_VALUE   6

Definition at line 169 of file c_can.c.

#define RECEIVE_OBJECT_BITS   0x0000ffff

Definition at line 159 of file c_can.c.

#define STATUS_BOFF   BIT(7)

Definition at line 72 of file c_can.c.

#define STATUS_EPASS   BIT(5)

Definition at line 74 of file c_can.c.

#define STATUS_EWARN   BIT(6)

Definition at line 73 of file c_can.c.

#define STATUS_INTERRUPT   0x8000

Definition at line 162 of file c_can.c.

#define STATUS_PDA   BIT(10)

Definition at line 71 of file c_can.c.

#define STATUS_RXOK   BIT(4)

Definition at line 75 of file c_can.c.

#define STATUS_TXOK   BIT(3)

Definition at line 76 of file c_can.c.

#define TEST_BASIC   BIT(2)

Definition at line 68 of file c_can.c.

#define TEST_LBACK   BIT(4)

Definition at line 66 of file c_can.c.

#define TEST_RX   BIT(7)

Definition at line 63 of file c_can.c.

#define TEST_SILENT   BIT(3)

Definition at line 67 of file c_can.c.

#define TEST_TX1   BIT(6)

Definition at line 64 of file c_can.c.

#define TEST_TX2   BIT(5)

Definition at line 65 of file c_can.c.

Enumeration Type Documentation

Enumerator:
C_CAN_NO_ERROR 
C_CAN_BUS_OFF 
C_CAN_ERROR_WARNING 
C_CAN_ERROR_PASSIVE 

Definition at line 193 of file c_can.c.

Enumerator:
LEC_NO_ERROR 
LEC_STUFF_ERROR 
LEC_FORM_ERROR 
LEC_ACK_ERROR 
LEC_BIT1_ERROR 
LEC_BIT0_ERROR 
LEC_CRC_ERROR 
LEC_UNUSED 

Definition at line 178 of file c_can.c.

Function Documentation

struct net_device* alloc_c_can_dev ( void  )
read

Definition at line 1139 of file c_can.c.

EXPORT_SYMBOL_GPL ( alloc_c_can_dev  )
EXPORT_SYMBOL_GPL ( free_c_can_dev  )
EXPORT_SYMBOL_GPL ( register_c_can_dev  )
EXPORT_SYMBOL_GPL ( unregister_c_can_dev  )
void free_c_can_dev ( struct net_device dev)

Definition at line 1234 of file c_can.c.

MODULE_AUTHOR ( "Bhupesh Sharma <[email protected]>"  )
MODULE_DESCRIPTION ( "CAN bus driver for Bosch C_CAN controller )
MODULE_LICENSE ( "GPL v2 )
int register_c_can_dev ( struct net_device dev)

Definition at line 1246 of file c_can.c.

void unregister_c_can_dev ( struct net_device dev)

Definition at line 1264 of file c_can.c.