2 * softing common interfaces
4 * by Kurt Van Dijck, 06-2008
7 #include <linux/interrupt.h>
8 #include <linux/netdevice.h>
10 #include <linux/can/dev.h>
15 /* special attribute, so we should not rely on the ->priv pointers
16 * before knowing how to interpret these
18 struct softing_attribute;
21 struct can_priv can; /* must be the first member! */
22 struct net_device *netdev;
26 /* variables wich hold the circular buffer */
30 struct can_bittiming_const btr_const;
34 struct attribute_group sysfs;
36 #define netdev2softing(netdev) ((struct softing_priv *)netdev_priv(netdev))
38 /* the 'all cards have the same' fields definition */
39 extern const struct can_bittiming_const softing_btr_const;
45 * 1st with NEC or SJA1000
46 * 8bit, exclusive interrupt, ...
48 * 16bit, shared interrupt
51 unsigned int freq; /*crystal in MHz */
54 unsigned long dpram_size;
65 struct softing_priv *bus[2];
66 spinlock_t spin; /* protect this structure & DPRAM access */
69 /* indication of firmware status */
71 /* protection of the 'up' variable */
77 struct tasklet_struct bh;
83 /* keep the bus that last tx'd a message,
84 * in order to let every netdev queue resume
92 struct softing_fct *fct;
93 struct softing_info *info;
94 struct softing_rx *rx;
95 struct softing_tx *tx;
96 struct softing_irq *irq;
97 unsigned short *command;
98 unsigned short *receipt;
103 u32 serial, fw, hw, lic;
108 const struct softing_desc *desc;
110 int (*reset) (struct softing *, int);
111 int (*enable_irq)(struct softing *, int);
115 struct attribute_group sysfs;
116 struct softing_attribute *attr;
117 struct attribute **grp;
120 extern int mk_softing(struct softing *);
121 /* fields that must be set already are :
128 extern void rm_softing(struct softing *);
129 /* usefull functions during operation */
131 extern const struct softing_desc *
132 softing_lookup_desc(unsigned int manf, unsigned int prod);
134 extern int softing_default_output(struct softing *card
135 , struct softing_priv *priv);
136 extern u32 softing_time2usec(struct softing *card, u32 raw);
138 extern int softing_fct_cmd(struct softing *card
139 , int cmd, int vector, const char *msg);
141 extern int softing_bootloader_command(struct softing *card
142 , int command, const char *msg);
144 /* Load firmware after reset */
145 extern int softing_load_fw(const char *file, struct softing *card,
146 unsigned char *virt, unsigned int size, int offset);
148 /* Load final application firmware after bootloader */
149 extern int softing_load_app_fw(const char *file, struct softing *card);
151 extern int softing_reset_chip(struct softing *card);
153 /* enable or disable irq
154 * only called with fw.lock locked
156 extern int softing_card_irq(struct softing *card, int enable);
158 /* called when tx queue is flushed */
159 extern void softing_flush_echo_skb(struct softing_priv *priv);
161 /* reinitaliase the card, apply -1 for bus[01] for 'no change' */
162 extern int softing_reinit(struct softing *card, int bus0, int bus1);
164 /* SOFTING DPRAM mappings */
173 } __attribute__((packed));
183 } __attribute__((packed));
188 } __attribute__((packed));
191 s16 param[20]; /* 0 is index */
195 } __attribute__((packed));
197 struct softing_info {
229 } __attribute__((packed));
231 /* DPRAM return codes */
235 #define RES_UNKNOWN 3
242 #define CMD_BUS2 0x80
245 extern int softing_debug;
247 #define mod_alert(fmt,arg...) { \
248 if (softing_debug >= 0) \
249 printk(KERN_ALERT "[%s] %s:" fmt "\n" \
250 , THIS_MODULE->name \
254 #define mod_info(fmt,arg...) { \
255 if (softing_debug >= 1) \
256 printk(KERN_INFO "[%s] %s:" fmt "\n"\
257 , THIS_MODULE->name \
261 #define mod_trace(fmt,arg...) { \
262 if (softing_debug >= 2) \
263 printk(KERN_DEBUG "[%s] %s:" fmt "\n" \
264 , THIS_MODULE->name \