aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/can
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /include/linux/can
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'include/linux/can')
-rw-r--r--include/linux/can/core.h6
-rw-r--r--include/linux/can/dev.h38
-rw-r--r--include/linux/can/platform/cc770.h33
3 files changed, 15 insertions, 62 deletions
diff --git a/include/linux/can/core.h b/include/linux/can/core.h
index 78c6c52073a..5ce6b5d62ec 100644
--- a/include/linux/can/core.h
+++ b/include/linux/can/core.h
@@ -8,6 +8,8 @@
8 * Copyright (c) 2002-2007 Volkswagen Group Electronic Research 8 * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Send feedback to <socketcan-users@lists.berlios.de>
12 *
11 */ 13 */
12 14
13#ifndef CAN_CORE_H 15#ifndef CAN_CORE_H
@@ -17,10 +19,10 @@
17#include <linux/skbuff.h> 19#include <linux/skbuff.h>
18#include <linux/netdevice.h> 20#include <linux/netdevice.h>
19 21
20#define CAN_VERSION "20120528" 22#define CAN_VERSION "20090105"
21 23
22/* increment this number each time you change some user-space interface */ 24/* increment this number each time you change some user-space interface */
23#define CAN_ABI_VERSION "9" 25#define CAN_ABI_VERSION "8"
24 26
25#define CAN_VERSION_STRING "rev " CAN_VERSION " abi " CAN_ABI_VERSION 27#define CAN_VERSION_STRING "rev " CAN_VERSION " abi " CAN_ABI_VERSION
26 28
diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h
index 2b2fc345afc..cc0bb496166 100644
--- a/include/linux/can/dev.h
+++ b/include/linux/can/dev.h
@@ -8,6 +8,7 @@
8 * 8 *
9 * Copyright (C) 2008 Wolfgang Grandegger <wg@grandegger.com> 9 * Copyright (C) 2008 Wolfgang Grandegger <wg@grandegger.com>
10 * 10 *
11 * Send feedback to <socketcan-users@lists.berlios.de>
11 */ 12 */
12 13
13#ifndef CAN_DEV_H 14#ifndef CAN_DEV_H
@@ -33,7 +34,7 @@ struct can_priv {
33 struct can_device_stats can_stats; 34 struct can_device_stats can_stats;
34 35
35 struct can_bittiming bittiming; 36 struct can_bittiming bittiming;
36 const struct can_bittiming_const *bittiming_const; 37 struct can_bittiming_const *bittiming_const;
37 struct can_clock clock; 38 struct can_clock clock;
38 39
39 enum can_state state; 40 enum can_state state;
@@ -61,40 +62,23 @@ struct can_priv {
61 * To be used in the CAN netdriver receive path to ensure conformance with 62 * To be used in the CAN netdriver receive path to ensure conformance with
62 * ISO 11898-1 Chapter 8.4.2.3 (DLC field) 63 * ISO 11898-1 Chapter 8.4.2.3 (DLC field)
63 */ 64 */
64#define get_can_dlc(i) (min_t(__u8, (i), CAN_MAX_DLC)) 65#define get_can_dlc(i) (min_t(__u8, (i), 8))
65#define get_canfd_dlc(i) (min_t(__u8, (i), CANFD_MAX_DLC))
66 66
67/* Drop a given socketbuffer if it does not contain a valid CAN frame. */ 67/* Drop a given socketbuffer if it does not contain a valid CAN frame. */
68static inline int can_dropped_invalid_skb(struct net_device *dev, 68static inline int can_dropped_invalid_skb(struct net_device *dev,
69 struct sk_buff *skb) 69 struct sk_buff *skb)
70{ 70{
71 const struct canfd_frame *cfd = (struct canfd_frame *)skb->data; 71 const struct can_frame *cf = (struct can_frame *)skb->data;
72
73 if (skb->protocol == htons(ETH_P_CAN)) {
74 if (unlikely(skb->len != CAN_MTU ||
75 cfd->len > CAN_MAX_DLEN))
76 goto inval_skb;
77 } else if (skb->protocol == htons(ETH_P_CANFD)) {
78 if (unlikely(skb->len != CANFD_MTU ||
79 cfd->len > CANFD_MAX_DLEN))
80 goto inval_skb;
81 } else
82 goto inval_skb;
83 72
84 return 0; 73 if (unlikely(skb->len != sizeof(*cf) || cf->can_dlc > 8)) {
74 kfree_skb(skb);
75 dev->stats.tx_dropped++;
76 return 1;
77 }
85 78
86inval_skb: 79 return 0;
87 kfree_skb(skb);
88 dev->stats.tx_dropped++;
89 return 1;
90} 80}
91 81
92/* get data length from can_dlc with sanitized can_dlc */
93u8 can_dlc2len(u8 can_dlc);
94
95/* map the sanitized data length to an appropriate data length code */
96u8 can_len2dlc(u8 len);
97
98struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max); 82struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max);
99void free_candev(struct net_device *dev); 83void free_candev(struct net_device *dev);
100 84
@@ -109,7 +93,7 @@ void can_bus_off(struct net_device *dev);
109 93
110void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, 94void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
111 unsigned int idx); 95 unsigned int idx);
112unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx); 96void can_get_echo_skb(struct net_device *dev, unsigned int idx);
113void can_free_echo_skb(struct net_device *dev, unsigned int idx); 97void can_free_echo_skb(struct net_device *dev, unsigned int idx);
114 98
115struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf); 99struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf);
diff --git a/include/linux/can/platform/cc770.h b/include/linux/can/platform/cc770.h
deleted file mode 100644
index 7702641f87e..00000000000
--- a/include/linux/can/platform/cc770.h
+++ /dev/null
@@ -1,33 +0,0 @@
1#ifndef _CAN_PLATFORM_CC770_H_
2#define _CAN_PLATFORM_CC770_H_
3
4/* CPU Interface Register (0x02) */
5#define CPUIF_CEN 0x01 /* Clock Out Enable */
6#define CPUIF_MUX 0x04 /* Multiplex */
7#define CPUIF_SLP 0x08 /* Sleep */
8#define CPUIF_PWD 0x10 /* Power Down Mode */
9#define CPUIF_DMC 0x20 /* Divide Memory Clock */
10#define CPUIF_DSC 0x40 /* Divide System Clock */
11#define CPUIF_RST 0x80 /* Hardware Reset Status */
12
13/* Clock Out Register (0x1f) */
14#define CLKOUT_CD_MASK 0x0f /* Clock Divider mask */
15#define CLKOUT_SL_MASK 0x30 /* Slew Rate mask */
16#define CLKOUT_SL_SHIFT 4
17
18/* Bus Configuration Register (0x2f) */
19#define BUSCFG_DR0 0x01 /* Disconnect RX0 Input / Select RX input */
20#define BUSCFG_DR1 0x02 /* Disconnect RX1 Input / Silent mode */
21#define BUSCFG_DT1 0x08 /* Disconnect TX1 Output */
22#define BUSCFG_POL 0x20 /* Polarity dominant or recessive */
23#define BUSCFG_CBY 0x40 /* Input Comparator Bypass */
24
25struct cc770_platform_data {
26 u32 osc_freq; /* CAN bus oscillator frequency in Hz */
27
28 u8 cir; /* CPU Interface Register */
29 u8 cor; /* Clock Out Register */
30 u8 bcr; /* Bus Configuration Register */
31};
32
33#endif /* !_CAN_PLATFORM_CC770_H_ */