2 * softing common interfaces
4 * by Kurt Van Dijck, 06-2008
7 #include <linux/interrupt.h>
8 #include <linux/netdevice.h>
9 #include <linux/ktime.h>
10 #include <socketcan/can.h>
11 #include <socketcan/can/dev.h>
16 /* softing firmware directory prefix */
17 #define fw_dir "softing-4.6/"
19 /* special attribute, so we should not rely on the ->priv pointers
20 * before knowing how to interpret these
22 struct softing_attribute;
25 struct can_priv can; /* must be the first member! */
26 struct net_device *netdev;
30 /* variables which hold the circular buffer */
34 struct can_bittiming_const btr_const;
38 struct attribute_group sysfs;
40 #define netdev2softing(netdev) ((struct softing_priv *)netdev_priv(netdev))
46 * 1st with NEC or SJA1000
47 * 8bit, exclusive interrupt, ...
49 * 16bit, shared interrupt
52 unsigned int freq; /*crystal in MHz */
55 unsigned long dpram_size;
66 struct softing_priv *bus[2];
67 spinlock_t spin; /* protect this structure & DPRAM access */
69 ktime_t ts_overflow; /* timestamp overflow value, in ktime */
72 /* indication of firmware status */
74 int failed; /* firmware has failed */
75 /* protection of the 'up' variable */
81 struct tasklet_struct bh;
87 /* keep the bus that last tx'd a message,
88 * in order to let every netdev queue resume
96 struct softing_fct *fct;
97 struct softing_info *info;
98 struct softing_rx *rx;
99 struct softing_tx *tx;
100 struct softing_irq *irq;
101 unsigned short *command;
102 unsigned short *receipt;
107 u32 serial, fw, hw, lic;
112 const struct softing_desc *desc;
114 int (*reset) (struct softing *, int);
115 int (*enable_irq)(struct softing *, int);
119 struct attribute_group sysfs;
120 struct softing_attribute *attr;
121 struct attribute **grp;
124 extern int mk_softing(struct softing *);
125 /* fields that must be set already are :
132 extern void rm_softing(struct softing *);
133 /* usefull functions during operation */
135 extern int softing_default_output(struct softing *card
136 , struct softing_priv *priv);
137 extern ktime_t softing_raw2ktime(struct softing *card, u32 raw);
139 extern int softing_fct_cmd(struct softing *card
140 , int cmd, int vector, const char *msg);
142 extern int softing_bootloader_command(struct softing *card
143 , int command, const char *msg);
145 /* Load firmware after reset */
146 extern int softing_load_fw(const char *file, struct softing *card,
147 unsigned char *virt, unsigned int size, int offset);
149 /* Load final application firmware after bootloader */
150 extern int softing_load_app_fw(const char *file, struct softing *card);
152 extern int softing_reset_chip(struct softing *card);
154 /* enable or disable irq
155 * only called with fw.lock locked
157 extern int softing_card_irq(struct softing *card, int enable);
159 /* start/stop 1 bus on cardr*/
160 extern int softing_cycle(
161 struct softing *card, struct softing_priv *priv, int up);
164 extern int softing_rx(struct net_device *netdev, const struct can_frame *msg,
167 /* create/remove the per-card associated sysfs entries */
168 extern int softing_card_sysfs_create(struct softing *card);
169 extern void softing_card_sysfs_remove(struct softing *card);
170 /* create/remove the per-bus associated sysfs entries */
171 extern int softing_bus_sysfs_create(struct softing_priv *bus);
172 extern void softing_bus_sysfs_remove(struct softing_priv *bus);
174 /* SOFTING DPRAM mappings */
183 } __attribute__((packed));
193 } __attribute__((packed));
198 } __attribute__((packed));
201 s16 param[20]; /* 0 is index */
205 } __attribute__((packed));
207 struct softing_info {
239 } __attribute__((packed));
241 /* DPRAM return codes */
245 #define RES_UNKNOWN 3
252 #define CMD_BUS2 0x80
255 extern int softing_debug;