diff options
Diffstat (limited to 'include/linux/can')
-rw-r--r-- | include/linux/can/core.h | 2 | ||||
-rw-r--r-- | include/linux/can/dev.h | 47 | ||||
-rw-r--r-- | include/linux/can/netlink.h | 17 | ||||
-rw-r--r-- | include/linux/can/platform/mcp251x.h | 36 | ||||
-rw-r--r-- | include/linux/can/platform/ti_hecc.h | 44 |
5 files changed, 133 insertions, 13 deletions
diff --git a/include/linux/can/core.h b/include/linux/can/core.h index 25085cbadcfc..6c507bea275f 100644 --- a/include/linux/can/core.h +++ b/include/linux/can/core.h | |||
@@ -32,14 +32,12 @@ | |||
32 | * struct can_proto - CAN protocol structure | 32 | * struct can_proto - CAN protocol structure |
33 | * @type: type argument in socket() syscall, e.g. SOCK_DGRAM. | 33 | * @type: type argument in socket() syscall, e.g. SOCK_DGRAM. |
34 | * @protocol: protocol number in socket() syscall. | 34 | * @protocol: protocol number in socket() syscall. |
35 | * @capability: capability needed to open the socket, or -1 for no restriction. | ||
36 | * @ops: pointer to struct proto_ops for sock->ops. | 35 | * @ops: pointer to struct proto_ops for sock->ops. |
37 | * @prot: pointer to struct proto structure. | 36 | * @prot: pointer to struct proto structure. |
38 | */ | 37 | */ |
39 | struct can_proto { | 38 | struct can_proto { |
40 | int type; | 39 | int type; |
41 | int protocol; | 40 | int protocol; |
42 | int capability; | ||
43 | struct proto_ops *ops; | 41 | struct proto_ops *ops; |
44 | struct proto *prot; | 42 | struct proto *prot; |
45 | }; | 43 | }; |
diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h index 5824b20b5fcb..6e5a7f00223d 100644 --- a/include/linux/can/dev.h +++ b/include/linux/can/dev.h | |||
@@ -29,8 +29,6 @@ enum can_mode { | |||
29 | /* | 29 | /* |
30 | * CAN common private data | 30 | * CAN common private data |
31 | */ | 31 | */ |
32 | #define CAN_ECHO_SKB_MAX 4 | ||
33 | |||
34 | struct can_priv { | 32 | struct can_priv { |
35 | struct can_device_stats can_stats; | 33 | struct can_device_stats can_stats; |
36 | 34 | ||
@@ -40,19 +38,47 @@ struct can_priv { | |||
40 | 38 | ||
41 | enum can_state state; | 39 | enum can_state state; |
42 | u32 ctrlmode; | 40 | u32 ctrlmode; |
41 | u32 ctrlmode_supported; | ||
43 | 42 | ||
44 | int restart_ms; | 43 | int restart_ms; |
45 | struct timer_list restart_timer; | 44 | struct timer_list restart_timer; |
46 | 45 | ||
47 | struct sk_buff *echo_skb[CAN_ECHO_SKB_MAX]; | ||
48 | |||
49 | int (*do_set_bittiming)(struct net_device *dev); | 46 | int (*do_set_bittiming)(struct net_device *dev); |
50 | int (*do_set_mode)(struct net_device *dev, enum can_mode mode); | 47 | int (*do_set_mode)(struct net_device *dev, enum can_mode mode); |
51 | int (*do_get_state)(const struct net_device *dev, | 48 | int (*do_get_state)(const struct net_device *dev, |
52 | enum can_state *state); | 49 | enum can_state *state); |
50 | int (*do_get_berr_counter)(const struct net_device *dev, | ||
51 | struct can_berr_counter *bec); | ||
52 | |||
53 | unsigned int echo_skb_max; | ||
54 | struct sk_buff **echo_skb; | ||
53 | }; | 55 | }; |
54 | 56 | ||
55 | struct net_device *alloc_candev(int sizeof_priv); | 57 | /* |
58 | * get_can_dlc(value) - helper macro to cast a given data length code (dlc) | ||
59 | * to __u8 and ensure the dlc value to be max. 8 bytes. | ||
60 | * | ||
61 | * 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 | */ | ||
64 | #define get_can_dlc(i) (min_t(__u8, (i), 8)) | ||
65 | |||
66 | /* Drop a given socketbuffer if it does not contain a valid CAN frame. */ | ||
67 | static inline int can_dropped_invalid_skb(struct net_device *dev, | ||
68 | struct sk_buff *skb) | ||
69 | { | ||
70 | const struct can_frame *cf = (struct can_frame *)skb->data; | ||
71 | |||
72 | if (unlikely(skb->len != sizeof(*cf) || cf->can_dlc > 8)) { | ||
73 | kfree_skb(skb); | ||
74 | dev->stats.tx_dropped++; | ||
75 | return 1; | ||
76 | } | ||
77 | |||
78 | return 0; | ||
79 | } | ||
80 | |||
81 | struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max); | ||
56 | void free_candev(struct net_device *dev); | 82 | void free_candev(struct net_device *dev); |
57 | 83 | ||
58 | int open_candev(struct net_device *dev); | 84 | int open_candev(struct net_device *dev); |
@@ -64,8 +90,13 @@ void unregister_candev(struct net_device *dev); | |||
64 | int can_restart_now(struct net_device *dev); | 90 | int can_restart_now(struct net_device *dev); |
65 | void can_bus_off(struct net_device *dev); | 91 | void can_bus_off(struct net_device *dev); |
66 | 92 | ||
67 | void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, int idx); | 93 | void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, |
68 | void can_get_echo_skb(struct net_device *dev, int idx); | 94 | unsigned int idx); |
69 | void can_free_echo_skb(struct net_device *dev, int idx); | 95 | void can_get_echo_skb(struct net_device *dev, unsigned int idx); |
96 | void can_free_echo_skb(struct net_device *dev, unsigned int idx); | ||
97 | |||
98 | struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf); | ||
99 | struct sk_buff *alloc_can_err_skb(struct net_device *dev, | ||
100 | struct can_frame **cf); | ||
70 | 101 | ||
71 | #endif /* CAN_DEV_H */ | 102 | #endif /* CAN_DEV_H */ |
diff --git a/include/linux/can/netlink.h b/include/linux/can/netlink.h index 9ecbb7871c0e..3250de935e1a 100644 --- a/include/linux/can/netlink.h +++ b/include/linux/can/netlink.h | |||
@@ -70,6 +70,14 @@ enum can_state { | |||
70 | }; | 70 | }; |
71 | 71 | ||
72 | /* | 72 | /* |
73 | * CAN bus error counters | ||
74 | */ | ||
75 | struct can_berr_counter { | ||
76 | __u16 txerr; | ||
77 | __u16 rxerr; | ||
78 | }; | ||
79 | |||
80 | /* | ||
73 | * CAN controller mode | 81 | * CAN controller mode |
74 | */ | 82 | */ |
75 | struct can_ctrlmode { | 83 | struct can_ctrlmode { |
@@ -77,9 +85,11 @@ struct can_ctrlmode { | |||
77 | __u32 flags; | 85 | __u32 flags; |
78 | }; | 86 | }; |
79 | 87 | ||
80 | #define CAN_CTRLMODE_LOOPBACK 0x1 /* Loopback mode */ | 88 | #define CAN_CTRLMODE_LOOPBACK 0x01 /* Loopback mode */ |
81 | #define CAN_CTRLMODE_LISTENONLY 0x2 /* Listen-only mode */ | 89 | #define CAN_CTRLMODE_LISTENONLY 0x02 /* Listen-only mode */ |
82 | #define CAN_CTRLMODE_3_SAMPLES 0x4 /* Triple sampling mode */ | 90 | #define CAN_CTRLMODE_3_SAMPLES 0x04 /* Triple sampling mode */ |
91 | #define CAN_CTRLMODE_ONE_SHOT 0x08 /* One-Shot mode */ | ||
92 | #define CAN_CTRLMODE_BERR_REPORTING 0x10 /* Bus-error reporting */ | ||
83 | 93 | ||
84 | /* | 94 | /* |
85 | * CAN device statistics | 95 | * CAN device statistics |
@@ -105,6 +115,7 @@ enum { | |||
105 | IFLA_CAN_CTRLMODE, | 115 | IFLA_CAN_CTRLMODE, |
106 | IFLA_CAN_RESTART_MS, | 116 | IFLA_CAN_RESTART_MS, |
107 | IFLA_CAN_RESTART, | 117 | IFLA_CAN_RESTART, |
118 | IFLA_CAN_BERR_COUNTER, | ||
108 | __IFLA_CAN_MAX | 119 | __IFLA_CAN_MAX |
109 | }; | 120 | }; |
110 | 121 | ||
diff --git a/include/linux/can/platform/mcp251x.h b/include/linux/can/platform/mcp251x.h new file mode 100644 index 000000000000..1448177d86d5 --- /dev/null +++ b/include/linux/can/platform/mcp251x.h | |||
@@ -0,0 +1,36 @@ | |||
1 | #ifndef __CAN_PLATFORM_MCP251X_H__ | ||
2 | #define __CAN_PLATFORM_MCP251X_H__ | ||
3 | |||
4 | /* | ||
5 | * | ||
6 | * CAN bus driver for Microchip 251x CAN Controller with SPI Interface | ||
7 | * | ||
8 | */ | ||
9 | |||
10 | #include <linux/spi/spi.h> | ||
11 | |||
12 | /** | ||
13 | * struct mcp251x_platform_data - MCP251X SPI CAN controller platform data | ||
14 | * @oscillator_frequency: - oscillator frequency in Hz | ||
15 | * @model: - actual type of chip | ||
16 | * @board_specific_setup: - called before probing the chip (power,reset) | ||
17 | * @transceiver_enable: - called to power on/off the transceiver | ||
18 | * @power_enable: - called to power on/off the mcp *and* the | ||
19 | * transceiver | ||
20 | * | ||
21 | * Please note that you should define power_enable or transceiver_enable or | ||
22 | * none of them. Defining both of them is no use. | ||
23 | * | ||
24 | */ | ||
25 | |||
26 | struct mcp251x_platform_data { | ||
27 | unsigned long oscillator_frequency; | ||
28 | int model; | ||
29 | #define CAN_MCP251X_MCP2510 0 | ||
30 | #define CAN_MCP251X_MCP2515 1 | ||
31 | int (*board_specific_setup)(struct spi_device *spi); | ||
32 | int (*transceiver_enable)(int enable); | ||
33 | int (*power_enable) (int enable); | ||
34 | }; | ||
35 | |||
36 | #endif /* __CAN_PLATFORM_MCP251X_H__ */ | ||
diff --git a/include/linux/can/platform/ti_hecc.h b/include/linux/can/platform/ti_hecc.h new file mode 100644 index 000000000000..af17cb3f7a84 --- /dev/null +++ b/include/linux/can/platform/ti_hecc.h | |||
@@ -0,0 +1,44 @@ | |||
1 | #ifndef __CAN_PLATFORM_TI_HECC_H__ | ||
2 | #define __CAN_PLATFORM_TI_HECC_H__ | ||
3 | |||
4 | /* | ||
5 | * TI HECC (High End CAN Controller) driver platform header | ||
6 | * | ||
7 | * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/ | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or | ||
10 | * modify it under the terms of the GNU General Public License as | ||
11 | * published by the Free Software Foundation version 2. | ||
12 | * | ||
13 | * This program is distributed as is WITHOUT ANY WARRANTY of any | ||
14 | * kind, whether express or implied; without even the implied warranty | ||
15 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | */ | ||
19 | |||
20 | /** | ||
21 | * struct hecc_platform_data - HECC Platform Data | ||
22 | * | ||
23 | * @scc_hecc_offset: mostly 0 - should really never change | ||
24 | * @scc_ram_offset: SCC RAM offset | ||
25 | * @hecc_ram_offset: HECC RAM offset | ||
26 | * @mbx_offset: Mailbox RAM offset | ||
27 | * @int_line: Interrupt line to use - 0 or 1 | ||
28 | * @version: version for future use | ||
29 | * @transceiver_switch: platform specific callback fn for transceiver control | ||
30 | * | ||
31 | * Platform data structure to get all platform specific settings. | ||
32 | * this structure also accounts the fact that the IP may have different | ||
33 | * RAM and mailbox offsets for different SOC's | ||
34 | */ | ||
35 | struct ti_hecc_platform_data { | ||
36 | u32 scc_hecc_offset; | ||
37 | u32 scc_ram_offset; | ||
38 | u32 hecc_ram_offset; | ||
39 | u32 mbx_offset; | ||
40 | u32 int_line; | ||
41 | u32 version; | ||
42 | void (*transceiver_switch) (int); | ||
43 | }; | ||
44 | #endif | ||