101
101
#define USBCAN_ERROR_STATE_RX_ERROR BIT(1)
102
102
#define USBCAN_ERROR_STATE_BUSERROR BIT(2)
103
103
104
- /* bittiming parameters */
105
- #define KVASER_USB_TSEG1_MIN 1
106
- #define KVASER_USB_TSEG1_MAX 16
107
- #define KVASER_USB_TSEG2_MIN 1
108
- #define KVASER_USB_TSEG2_MAX 8
109
- #define KVASER_USB_SJW_MAX 4
110
- #define KVASER_USB_BRP_MIN 1
111
- #define KVASER_USB_BRP_MAX 64
112
- #define KVASER_USB_BRP_INC 1
113
-
114
104
/* ctrl modes */
115
105
#define KVASER_CTRL_MODE_NORMAL 1
116
106
#define KVASER_CTRL_MODE_SILENT 2
@@ -343,48 +333,68 @@ struct kvaser_usb_err_summary {
343
333
};
344
334
};
345
335
346
- static const struct can_bittiming_const kvaser_usb_leaf_bittiming_const = {
347
- .name = "kvaser_usb" ,
348
- .tseg1_min = KVASER_USB_TSEG1_MIN ,
349
- .tseg1_max = KVASER_USB_TSEG1_MAX ,
350
- .tseg2_min = KVASER_USB_TSEG2_MIN ,
351
- .tseg2_max = KVASER_USB_TSEG2_MAX ,
352
- .sjw_max = KVASER_USB_SJW_MAX ,
353
- .brp_min = KVASER_USB_BRP_MIN ,
354
- .brp_max = KVASER_USB_BRP_MAX ,
355
- .brp_inc = KVASER_USB_BRP_INC ,
336
+ static const struct can_bittiming_const kvaser_usb_leaf_m16c_bittiming_const = {
337
+ .name = "kvaser_usb_ucii" ,
338
+ .tseg1_min = 4 ,
339
+ .tseg1_max = 16 ,
340
+ .tseg2_min = 2 ,
341
+ .tseg2_max = 8 ,
342
+ .sjw_max = 4 ,
343
+ .brp_min = 1 ,
344
+ .brp_max = 16 ,
345
+ .brp_inc = 1 ,
346
+ };
347
+
348
+ static const struct can_bittiming_const kvaser_usb_leaf_m32c_bittiming_const = {
349
+ .name = "kvaser_usb_leaf" ,
350
+ .tseg1_min = 3 ,
351
+ .tseg1_max = 16 ,
352
+ .tseg2_min = 2 ,
353
+ .tseg2_max = 8 ,
354
+ .sjw_max = 4 ,
355
+ .brp_min = 2 ,
356
+ .brp_max = 128 ,
357
+ .brp_inc = 2 ,
356
358
};
357
359
358
- static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_dev_cfg_8mhz = {
360
+ static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_usbcan_dev_cfg = {
359
361
.clock = {
360
362
.freq = 8 * MEGA /* Hz */ ,
361
363
},
362
364
.timestamp_freq = 1 ,
363
- .bittiming_const = & kvaser_usb_leaf_bittiming_const ,
365
+ .bittiming_const = & kvaser_usb_leaf_m16c_bittiming_const ,
366
+ };
367
+
368
+ static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_m32c_dev_cfg = {
369
+ .clock = {
370
+ .freq = 16 * MEGA /* Hz */ ,
371
+ },
372
+ .timestamp_freq = 1 ,
373
+ .bittiming_const = & kvaser_usb_leaf_m32c_bittiming_const ,
364
374
};
365
375
366
- static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_dev_cfg_16mhz = {
376
+ static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_imx_dev_cfg_16mhz = {
367
377
.clock = {
368
378
.freq = 16 * MEGA /* Hz */ ,
369
379
},
370
380
.timestamp_freq = 1 ,
371
- .bittiming_const = & kvaser_usb_leaf_bittiming_const ,
381
+ .bittiming_const = & kvaser_usb_flexc_bittiming_const ,
372
382
};
373
383
374
- static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_dev_cfg_24mhz = {
384
+ static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_imx_dev_cfg_24mhz = {
375
385
.clock = {
376
386
.freq = 24 * MEGA /* Hz */ ,
377
387
},
378
388
.timestamp_freq = 1 ,
379
- .bittiming_const = & kvaser_usb_leaf_bittiming_const ,
389
+ .bittiming_const = & kvaser_usb_flexc_bittiming_const ,
380
390
};
381
391
382
- static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_dev_cfg_32mhz = {
392
+ static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_imx_dev_cfg_32mhz = {
383
393
.clock = {
384
394
.freq = 32 * MEGA /* Hz */ ,
385
395
},
386
396
.timestamp_freq = 1 ,
387
- .bittiming_const = & kvaser_usb_leaf_bittiming_const ,
397
+ .bittiming_const = & kvaser_usb_flexc_bittiming_const ,
388
398
};
389
399
390
400
static void *
@@ -528,17 +538,17 @@ static void kvaser_usb_leaf_get_software_info_leaf(struct kvaser_usb *dev,
528
538
/* Firmware expects bittiming parameters calculated for 16MHz
529
539
* clock, regardless of the actual clock
530
540
*/
531
- dev -> cfg = & kvaser_usb_leaf_dev_cfg_16mhz ;
541
+ dev -> cfg = & kvaser_usb_leaf_m32c_dev_cfg ;
532
542
} else {
533
543
switch (sw_options & KVASER_USB_LEAF_SWOPTION_FREQ_MASK ) {
534
544
case KVASER_USB_LEAF_SWOPTION_FREQ_16_MHZ_CLK :
535
- dev -> cfg = & kvaser_usb_leaf_dev_cfg_16mhz ;
545
+ dev -> cfg = & kvaser_usb_leaf_imx_dev_cfg_16mhz ;
536
546
break ;
537
547
case KVASER_USB_LEAF_SWOPTION_FREQ_24_MHZ_CLK :
538
- dev -> cfg = & kvaser_usb_leaf_dev_cfg_24mhz ;
548
+ dev -> cfg = & kvaser_usb_leaf_imx_dev_cfg_24mhz ;
539
549
break ;
540
550
case KVASER_USB_LEAF_SWOPTION_FREQ_32_MHZ_CLK :
541
- dev -> cfg = & kvaser_usb_leaf_dev_cfg_32mhz ;
551
+ dev -> cfg = & kvaser_usb_leaf_imx_dev_cfg_32mhz ;
542
552
break ;
543
553
}
544
554
}
@@ -565,7 +575,7 @@ static int kvaser_usb_leaf_get_software_info_inner(struct kvaser_usb *dev)
565
575
dev -> fw_version = le32_to_cpu (cmd .u .usbcan .softinfo .fw_version );
566
576
dev -> max_tx_urbs =
567
577
le16_to_cpu (cmd .u .usbcan .softinfo .max_outstanding_tx );
568
- dev -> cfg = & kvaser_usb_leaf_dev_cfg_8mhz ;
578
+ dev -> cfg = & kvaser_usb_leaf_usbcan_dev_cfg ;
569
579
break ;
570
580
}
571
581
0 commit comments