diff options
Diffstat (limited to 'include/linux/can')
| -rw-r--r-- | include/linux/can/Kbuild | 1 | ||||
| -rw-r--r-- | include/linux/can/dev.h | 70 | ||||
| -rw-r--r-- | include/linux/can/netlink.h | 113 | ||||
| -rw-r--r-- | include/linux/can/platform/sja1000.h | 35 |
4 files changed, 219 insertions, 0 deletions
diff --git a/include/linux/can/Kbuild b/include/linux/can/Kbuild index eff898aac02b..8cb05aae661c 100644 --- a/include/linux/can/Kbuild +++ b/include/linux/can/Kbuild | |||
| @@ -1,3 +1,4 @@ | |||
| 1 | header-y += raw.h | 1 | header-y += raw.h |
| 2 | header-y += bcm.h | 2 | header-y += bcm.h |
| 3 | header-y += error.h | 3 | header-y += error.h |
| 4 | header-y += netlink.h | ||
diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h new file mode 100644 index 000000000000..4a37a56f6cdd --- /dev/null +++ b/include/linux/can/dev.h | |||
| @@ -0,0 +1,70 @@ | |||
| 1 | /* | ||
| 2 | * linux/can/dev.h | ||
| 3 | * | ||
| 4 | * Definitions for the CAN network device driver interface | ||
| 5 | * | ||
| 6 | * Copyright (C) 2006 Andrey Volkov <avolkov@varma-el.com> | ||
| 7 | * Varma Electronics Oy | ||
| 8 | * | ||
| 9 | * Copyright (C) 2008 Wolfgang Grandegger <wg@grandegger.com> | ||
| 10 | * | ||
| 11 | * Send feedback to <socketcan-users@lists.berlios.de> | ||
| 12 | */ | ||
| 13 | |||
| 14 | #ifndef CAN_DEV_H | ||
| 15 | #define CAN_DEV_H | ||
| 16 | |||
| 17 | #include <linux/can/netlink.h> | ||
| 18 | #include <linux/can/error.h> | ||
| 19 | |||
| 20 | /* | ||
| 21 | * CAN mode | ||
| 22 | */ | ||
| 23 | enum can_mode { | ||
| 24 | CAN_MODE_STOP = 0, | ||
| 25 | CAN_MODE_START, | ||
| 26 | CAN_MODE_SLEEP | ||
| 27 | }; | ||
| 28 | |||
| 29 | /* | ||
| 30 | * CAN common private data | ||
| 31 | */ | ||
| 32 | #define CAN_ECHO_SKB_MAX 4 | ||
| 33 | |||
| 34 | struct can_priv { | ||
| 35 | struct can_device_stats can_stats; | ||
| 36 | |||
| 37 | struct can_bittiming bittiming; | ||
| 38 | struct can_bittiming_const *bittiming_const; | ||
| 39 | struct can_clock clock; | ||
| 40 | |||
| 41 | enum can_state state; | ||
| 42 | u32 ctrlmode; | ||
| 43 | |||
| 44 | int restart_ms; | ||
| 45 | struct timer_list restart_timer; | ||
| 46 | |||
| 47 | struct sk_buff *echo_skb[CAN_ECHO_SKB_MAX]; | ||
| 48 | |||
| 49 | int (*do_set_bittiming)(struct net_device *dev); | ||
| 50 | int (*do_set_mode)(struct net_device *dev, enum can_mode mode); | ||
| 51 | int (*do_get_state)(const struct net_device *dev, | ||
| 52 | enum can_state *state); | ||
| 53 | }; | ||
| 54 | |||
| 55 | struct net_device *alloc_candev(int sizeof_priv); | ||
| 56 | void free_candev(struct net_device *dev); | ||
| 57 | |||
| 58 | int open_candev(struct net_device *dev); | ||
| 59 | void close_candev(struct net_device *dev); | ||
| 60 | |||
| 61 | int register_candev(struct net_device *dev); | ||
| 62 | void unregister_candev(struct net_device *dev); | ||
| 63 | |||
| 64 | int can_restart_now(struct net_device *dev); | ||
| 65 | void can_bus_off(struct net_device *dev); | ||
| 66 | |||
| 67 | void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, int idx); | ||
| 68 | void can_get_echo_skb(struct net_device *dev, int idx); | ||
| 69 | |||
| 70 | #endif /* CAN_DEV_H */ | ||
diff --git a/include/linux/can/netlink.h b/include/linux/can/netlink.h new file mode 100644 index 000000000000..9ecbb7871c0e --- /dev/null +++ b/include/linux/can/netlink.h | |||
| @@ -0,0 +1,113 @@ | |||
| 1 | /* | ||
| 2 | * linux/can/netlink.h | ||
| 3 | * | ||
| 4 | * Definitions for the CAN netlink interface | ||
| 5 | * | ||
| 6 | * Copyright (c) 2009 Wolfgang Grandegger <wg@grandegger.com> | ||
| 7 | * | ||
| 8 | * Send feedback to <socketcan-users@lists.berlios.de> | ||
| 9 | * | ||
| 10 | */ | ||
| 11 | |||
| 12 | #ifndef CAN_NETLINK_H | ||
| 13 | #define CAN_NETLINK_H | ||
| 14 | |||
| 15 | #include <linux/types.h> | ||
| 16 | |||
| 17 | /* | ||
| 18 | * CAN bit-timing parameters | ||
| 19 | * | ||
| 20 | * For futher information, please read chapter "8 BIT TIMING | ||
| 21 | * REQUIREMENTS" of the "Bosch CAN Specification version 2.0" | ||
| 22 | * at http://www.semiconductors.bosch.de/pdf/can2spec.pdf. | ||
| 23 | */ | ||
| 24 | struct can_bittiming { | ||
| 25 | __u32 bitrate; /* Bit-rate in bits/second */ | ||
| 26 | __u32 sample_point; /* Sample point in one-tenth of a percent */ | ||
| 27 | __u32 tq; /* Time quanta (TQ) in nanoseconds */ | ||
| 28 | __u32 prop_seg; /* Propagation segment in TQs */ | ||
| 29 | __u32 phase_seg1; /* Phase buffer segment 1 in TQs */ | ||
| 30 | __u32 phase_seg2; /* Phase buffer segment 2 in TQs */ | ||
| 31 | __u32 sjw; /* Synchronisation jump width in TQs */ | ||
| 32 | __u32 brp; /* Bit-rate prescaler */ | ||
| 33 | }; | ||
| 34 | |||
| 35 | /* | ||
| 36 | * CAN harware-dependent bit-timing constant | ||
| 37 | * | ||
| 38 | * Used for calculating and checking bit-timing parameters | ||
| 39 | */ | ||
| 40 | struct can_bittiming_const { | ||
| 41 | char name[16]; /* Name of the CAN controller hardware */ | ||
| 42 | __u32 tseg1_min; /* Time segement 1 = prop_seg + phase_seg1 */ | ||
| 43 | __u32 tseg1_max; | ||
| 44 | __u32 tseg2_min; /* Time segement 2 = phase_seg2 */ | ||
| 45 | __u32 tseg2_max; | ||
| 46 | __u32 sjw_max; /* Synchronisation jump width */ | ||
| 47 | __u32 brp_min; /* Bit-rate prescaler */ | ||
| 48 | __u32 brp_max; | ||
| 49 | __u32 brp_inc; | ||
| 50 | }; | ||
| 51 | |||
| 52 | /* | ||
| 53 | * CAN clock parameters | ||
| 54 | */ | ||
| 55 | struct can_clock { | ||
| 56 | __u32 freq; /* CAN system clock frequency in Hz */ | ||
| 57 | }; | ||
| 58 | |||
| 59 | /* | ||
| 60 | * CAN operational and error states | ||
| 61 | */ | ||
| 62 | enum can_state { | ||
| 63 | CAN_STATE_ERROR_ACTIVE = 0, /* RX/TX error count < 96 */ | ||
| 64 | CAN_STATE_ERROR_WARNING, /* RX/TX error count < 128 */ | ||
| 65 | CAN_STATE_ERROR_PASSIVE, /* RX/TX error count < 256 */ | ||
| 66 | CAN_STATE_BUS_OFF, /* RX/TX error count >= 256 */ | ||
| 67 | CAN_STATE_STOPPED, /* Device is stopped */ | ||
| 68 | CAN_STATE_SLEEPING, /* Device is sleeping */ | ||
| 69 | CAN_STATE_MAX | ||
| 70 | }; | ||
| 71 | |||
| 72 | /* | ||
| 73 | * CAN controller mode | ||
| 74 | */ | ||
| 75 | struct can_ctrlmode { | ||
| 76 | __u32 mask; | ||
| 77 | __u32 flags; | ||
| 78 | }; | ||
| 79 | |||
| 80 | #define CAN_CTRLMODE_LOOPBACK 0x1 /* Loopback mode */ | ||
| 81 | #define CAN_CTRLMODE_LISTENONLY 0x2 /* Listen-only mode */ | ||
| 82 | #define CAN_CTRLMODE_3_SAMPLES 0x4 /* Triple sampling mode */ | ||
| 83 | |||
| 84 | /* | ||
| 85 | * CAN device statistics | ||
| 86 | */ | ||
| 87 | struct can_device_stats { | ||
| 88 | __u32 bus_error; /* Bus errors */ | ||
| 89 | __u32 error_warning; /* Changes to error warning state */ | ||
| 90 | __u32 error_passive; /* Changes to error passive state */ | ||
| 91 | __u32 bus_off; /* Changes to bus off state */ | ||
| 92 | __u32 arbitration_lost; /* Arbitration lost errors */ | ||
| 93 | __u32 restarts; /* CAN controller re-starts */ | ||
| 94 | }; | ||
| 95 | |||
| 96 | /* | ||
| 97 | * CAN netlink interface | ||
| 98 | */ | ||
| 99 | enum { | ||
| 100 | IFLA_CAN_UNSPEC, | ||
| 101 | IFLA_CAN_BITTIMING, | ||
| 102 | IFLA_CAN_BITTIMING_CONST, | ||
| 103 | IFLA_CAN_CLOCK, | ||
| 104 | IFLA_CAN_STATE, | ||
| 105 | IFLA_CAN_CTRLMODE, | ||
| 106 | IFLA_CAN_RESTART_MS, | ||
| 107 | IFLA_CAN_RESTART, | ||
| 108 | __IFLA_CAN_MAX | ||
| 109 | }; | ||
| 110 | |||
| 111 | #define IFLA_CAN_MAX (__IFLA_CAN_MAX - 1) | ||
| 112 | |||
| 113 | #endif /* CAN_NETLINK_H */ | ||
diff --git a/include/linux/can/platform/sja1000.h b/include/linux/can/platform/sja1000.h new file mode 100644 index 000000000000..01ee2aeb048d --- /dev/null +++ b/include/linux/can/platform/sja1000.h | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | #ifndef _CAN_PLATFORM_SJA1000_H_ | ||
| 2 | #define _CAN_PLATFORM_SJA1000_H_ | ||
| 3 | |||
| 4 | /* clock divider register */ | ||
| 5 | #define CDR_CLKOUT_MASK 0x07 | ||
| 6 | #define CDR_CLK_OFF 0x08 /* Clock off (CLKOUT pin) */ | ||
| 7 | #define CDR_RXINPEN 0x20 /* TX1 output is RX irq output */ | ||
| 8 | #define CDR_CBP 0x40 /* CAN input comparator bypass */ | ||
| 9 | #define CDR_PELICAN 0x80 /* PeliCAN mode */ | ||
| 10 | |||
| 11 | /* output control register */ | ||
| 12 | #define OCR_MODE_BIPHASE 0x00 | ||
| 13 | #define OCR_MODE_TEST 0x01 | ||
| 14 | #define OCR_MODE_NORMAL 0x02 | ||
| 15 | #define OCR_MODE_CLOCK 0x03 | ||
| 16 | #define OCR_MODE_MASK 0x07 | ||
| 17 | #define OCR_TX0_INVERT 0x04 | ||
| 18 | #define OCR_TX0_PULLDOWN 0x08 | ||
| 19 | #define OCR_TX0_PULLUP 0x10 | ||
| 20 | #define OCR_TX0_PUSHPULL 0x18 | ||
| 21 | #define OCR_TX1_INVERT 0x20 | ||
| 22 | #define OCR_TX1_PULLDOWN 0x40 | ||
| 23 | #define OCR_TX1_PULLUP 0x80 | ||
| 24 | #define OCR_TX1_PUSHPULL 0xc0 | ||
| 25 | #define OCR_TX_MASK 0xfc | ||
| 26 | #define OCR_TX_SHIFT 2 | ||
| 27 | |||
| 28 | struct sja1000_platform_data { | ||
| 29 | u32 clock; /* CAN bus oscillator frequency in Hz */ | ||
| 30 | |||
| 31 | u8 ocr; /* output control register */ | ||
| 32 | u8 cdr; /* clock divider register */ | ||
| 33 | }; | ||
| 34 | |||
| 35 | #endif /* !_CAN_PLATFORM_SJA1000_H_ */ | ||
