Commit f0d21e89 authored by David S. Miller's avatar David S. Miller

Merge tag 'linux-can-fixes-for-4.9-20161201' of...

Merge tag 'linux-can-fixes-for-4.9-20161201' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can

Marc Kleine-Budde says:

====================
pull-request: can 2016-12-02

this is a pull request for net/master.

There are two patches by Stephane Grosjean, who adds support for the new
PCAN-USB X6 USB interface to the pcan_usb driver.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 50d5aa4c f00b534d
...@@ -43,11 +43,22 @@ struct __packed pucan_command { ...@@ -43,11 +43,22 @@ struct __packed pucan_command {
u16 args[3]; u16 args[3];
}; };
#define PUCAN_TSLOW_BRP_BITS 10
#define PUCAN_TSLOW_TSGEG1_BITS 8
#define PUCAN_TSLOW_TSGEG2_BITS 7
#define PUCAN_TSLOW_SJW_BITS 7
#define PUCAN_TSLOW_BRP_MASK ((1 << PUCAN_TSLOW_BRP_BITS) - 1)
#define PUCAN_TSLOW_TSEG1_MASK ((1 << PUCAN_TSLOW_TSGEG1_BITS) - 1)
#define PUCAN_TSLOW_TSEG2_MASK ((1 << PUCAN_TSLOW_TSGEG2_BITS) - 1)
#define PUCAN_TSLOW_SJW_MASK ((1 << PUCAN_TSLOW_SJW_BITS) - 1)
/* uCAN TIMING_SLOW command fields */ /* uCAN TIMING_SLOW command fields */
#define PUCAN_TSLOW_SJW_T(s, t) (((s) & 0xf) | ((!!(t)) << 7)) #define PUCAN_TSLOW_SJW_T(s, t) (((s) & PUCAN_TSLOW_SJW_MASK) | \
#define PUCAN_TSLOW_TSEG2(t) ((t) & 0xf) ((!!(t)) << 7))
#define PUCAN_TSLOW_TSEG1(t) ((t) & 0x3f) #define PUCAN_TSLOW_TSEG2(t) ((t) & PUCAN_TSLOW_TSEG2_MASK)
#define PUCAN_TSLOW_BRP(b) ((b) & 0x3ff) #define PUCAN_TSLOW_TSEG1(t) ((t) & PUCAN_TSLOW_TSEG1_MASK)
#define PUCAN_TSLOW_BRP(b) ((b) & PUCAN_TSLOW_BRP_MASK)
struct __packed pucan_timing_slow { struct __packed pucan_timing_slow {
__le16 opcode_channel; __le16 opcode_channel;
...@@ -60,11 +71,21 @@ struct __packed pucan_timing_slow { ...@@ -60,11 +71,21 @@ struct __packed pucan_timing_slow {
__le16 brp; /* BaudRate Prescaler */ __le16 brp; /* BaudRate Prescaler */
}; };
#define PUCAN_TFAST_BRP_BITS 10
#define PUCAN_TFAST_TSGEG1_BITS 5
#define PUCAN_TFAST_TSGEG2_BITS 4
#define PUCAN_TFAST_SJW_BITS 4
#define PUCAN_TFAST_BRP_MASK ((1 << PUCAN_TFAST_BRP_BITS) - 1)
#define PUCAN_TFAST_TSEG1_MASK ((1 << PUCAN_TFAST_TSGEG1_BITS) - 1)
#define PUCAN_TFAST_TSEG2_MASK ((1 << PUCAN_TFAST_TSGEG2_BITS) - 1)
#define PUCAN_TFAST_SJW_MASK ((1 << PUCAN_TFAST_SJW_BITS) - 1)
/* uCAN TIMING_FAST command fields */ /* uCAN TIMING_FAST command fields */
#define PUCAN_TFAST_SJW(s) ((s) & 0x3) #define PUCAN_TFAST_SJW(s) ((s) & PUCAN_TFAST_SJW_MASK)
#define PUCAN_TFAST_TSEG2(t) ((t) & 0x7) #define PUCAN_TFAST_TSEG2(t) ((t) & PUCAN_TFAST_TSEG2_MASK)
#define PUCAN_TFAST_TSEG1(t) ((t) & 0xf) #define PUCAN_TFAST_TSEG1(t) ((t) & PUCAN_TFAST_TSEG1_MASK)
#define PUCAN_TFAST_BRP(b) ((b) & 0x3ff) #define PUCAN_TFAST_BRP(b) ((b) & PUCAN_TFAST_BRP_MASK)
struct __packed pucan_timing_fast { struct __packed pucan_timing_fast {
__le16 opcode_channel; __le16 opcode_channel;
......
...@@ -39,6 +39,7 @@ static struct usb_device_id peak_usb_table[] = { ...@@ -39,6 +39,7 @@ static struct usb_device_id peak_usb_table[] = {
{USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBPRO_PRODUCT_ID)}, {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBPRO_PRODUCT_ID)},
{USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBFD_PRODUCT_ID)}, {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBFD_PRODUCT_ID)},
{USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBPROFD_PRODUCT_ID)}, {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBPROFD_PRODUCT_ID)},
{USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBX6_PRODUCT_ID)},
{} /* Terminating entry */ {} /* Terminating entry */
}; };
...@@ -50,6 +51,7 @@ static const struct peak_usb_adapter *const peak_usb_adapters_list[] = { ...@@ -50,6 +51,7 @@ static const struct peak_usb_adapter *const peak_usb_adapters_list[] = {
&pcan_usb_pro, &pcan_usb_pro,
&pcan_usb_fd, &pcan_usb_fd,
&pcan_usb_pro_fd, &pcan_usb_pro_fd,
&pcan_usb_x6,
}; };
/* /*
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#define PCAN_USBPRO_PRODUCT_ID 0x000d #define PCAN_USBPRO_PRODUCT_ID 0x000d
#define PCAN_USBPROFD_PRODUCT_ID 0x0011 #define PCAN_USBPROFD_PRODUCT_ID 0x0011
#define PCAN_USBFD_PRODUCT_ID 0x0012 #define PCAN_USBFD_PRODUCT_ID 0x0012
#define PCAN_USBX6_PRODUCT_ID 0x0014
#define PCAN_USB_DRIVER_NAME "peak_usb" #define PCAN_USB_DRIVER_NAME "peak_usb"
...@@ -90,6 +91,7 @@ extern const struct peak_usb_adapter pcan_usb; ...@@ -90,6 +91,7 @@ extern const struct peak_usb_adapter pcan_usb;
extern const struct peak_usb_adapter pcan_usb_pro; extern const struct peak_usb_adapter pcan_usb_pro;
extern const struct peak_usb_adapter pcan_usb_fd; extern const struct peak_usb_adapter pcan_usb_fd;
extern const struct peak_usb_adapter pcan_usb_pro_fd; extern const struct peak_usb_adapter pcan_usb_pro_fd;
extern const struct peak_usb_adapter pcan_usb_x6;
struct peak_time_ref { struct peak_time_ref {
struct timeval tv_host_0, tv_host; struct timeval tv_host_0, tv_host;
......
...@@ -993,24 +993,24 @@ static void pcan_usb_fd_free(struct peak_usb_device *dev) ...@@ -993,24 +993,24 @@ static void pcan_usb_fd_free(struct peak_usb_device *dev)
static const struct can_bittiming_const pcan_usb_fd_const = { static const struct can_bittiming_const pcan_usb_fd_const = {
.name = "pcan_usb_fd", .name = "pcan_usb_fd",
.tseg1_min = 1, .tseg1_min = 1,
.tseg1_max = 64, .tseg1_max = (1 << PUCAN_TSLOW_TSGEG1_BITS),
.tseg2_min = 1, .tseg2_min = 1,
.tseg2_max = 16, .tseg2_max = (1 << PUCAN_TSLOW_TSGEG2_BITS),
.sjw_max = 16, .sjw_max = (1 << PUCAN_TSLOW_SJW_BITS),
.brp_min = 1, .brp_min = 1,
.brp_max = 1024, .brp_max = (1 << PUCAN_TSLOW_BRP_BITS),
.brp_inc = 1, .brp_inc = 1,
}; };
static const struct can_bittiming_const pcan_usb_fd_data_const = { static const struct can_bittiming_const pcan_usb_fd_data_const = {
.name = "pcan_usb_fd", .name = "pcan_usb_fd",
.tseg1_min = 1, .tseg1_min = 1,
.tseg1_max = 16, .tseg1_max = (1 << PUCAN_TFAST_TSGEG1_BITS),
.tseg2_min = 1, .tseg2_min = 1,
.tseg2_max = 8, .tseg2_max = (1 << PUCAN_TFAST_TSGEG2_BITS),
.sjw_max = 4, .sjw_max = (1 << PUCAN_TFAST_SJW_BITS),
.brp_min = 1, .brp_min = 1,
.brp_max = 1024, .brp_max = (1 << PUCAN_TFAST_BRP_BITS),
.brp_inc = 1, .brp_inc = 1,
}; };
...@@ -1065,24 +1065,24 @@ const struct peak_usb_adapter pcan_usb_fd = { ...@@ -1065,24 +1065,24 @@ const struct peak_usb_adapter pcan_usb_fd = {
static const struct can_bittiming_const pcan_usb_pro_fd_const = { static const struct can_bittiming_const pcan_usb_pro_fd_const = {
.name = "pcan_usb_pro_fd", .name = "pcan_usb_pro_fd",
.tseg1_min = 1, .tseg1_min = 1,
.tseg1_max = 64, .tseg1_max = (1 << PUCAN_TSLOW_TSGEG1_BITS),
.tseg2_min = 1, .tseg2_min = 1,
.tseg2_max = 16, .tseg2_max = (1 << PUCAN_TSLOW_TSGEG2_BITS),
.sjw_max = 16, .sjw_max = (1 << PUCAN_TSLOW_SJW_BITS),
.brp_min = 1, .brp_min = 1,
.brp_max = 1024, .brp_max = (1 << PUCAN_TSLOW_BRP_BITS),
.brp_inc = 1, .brp_inc = 1,
}; };
static const struct can_bittiming_const pcan_usb_pro_fd_data_const = { static const struct can_bittiming_const pcan_usb_pro_fd_data_const = {
.name = "pcan_usb_pro_fd", .name = "pcan_usb_pro_fd",
.tseg1_min = 1, .tseg1_min = 1,
.tseg1_max = 16, .tseg1_max = (1 << PUCAN_TFAST_TSGEG1_BITS),
.tseg2_min = 1, .tseg2_min = 1,
.tseg2_max = 8, .tseg2_max = (1 << PUCAN_TFAST_TSGEG2_BITS),
.sjw_max = 4, .sjw_max = (1 << PUCAN_TFAST_SJW_BITS),
.brp_min = 1, .brp_min = 1,
.brp_max = 1024, .brp_max = (1 << PUCAN_TFAST_BRP_BITS),
.brp_inc = 1, .brp_inc = 1,
}; };
...@@ -1132,3 +1132,75 @@ const struct peak_usb_adapter pcan_usb_pro_fd = { ...@@ -1132,3 +1132,75 @@ const struct peak_usb_adapter pcan_usb_pro_fd = {
.do_get_berr_counter = pcan_usb_fd_get_berr_counter, .do_get_berr_counter = pcan_usb_fd_get_berr_counter,
}; };
/* describes the PCAN-USB X6 adapter */
static const struct can_bittiming_const pcan_usb_x6_const = {
.name = "pcan_usb_x6",
.tseg1_min = 1,
.tseg1_max = (1 << PUCAN_TSLOW_TSGEG1_BITS),
.tseg2_min = 1,
.tseg2_max = (1 << PUCAN_TSLOW_TSGEG2_BITS),
.sjw_max = (1 << PUCAN_TSLOW_SJW_BITS),
.brp_min = 1,
.brp_max = (1 << PUCAN_TSLOW_BRP_BITS),
.brp_inc = 1,
};
static const struct can_bittiming_const pcan_usb_x6_data_const = {
.name = "pcan_usb_x6",
.tseg1_min = 1,
.tseg1_max = (1 << PUCAN_TFAST_TSGEG1_BITS),
.tseg2_min = 1,
.tseg2_max = (1 << PUCAN_TFAST_TSGEG2_BITS),
.sjw_max = (1 << PUCAN_TFAST_SJW_BITS),
.brp_min = 1,
.brp_max = (1 << PUCAN_TFAST_BRP_BITS),
.brp_inc = 1,
};
const struct peak_usb_adapter pcan_usb_x6 = {
.name = "PCAN-USB X6",
.device_id = PCAN_USBX6_PRODUCT_ID,
.ctrl_count = PCAN_USBPROFD_CHANNEL_COUNT,
.ctrlmode_supported = CAN_CTRLMODE_FD |
CAN_CTRLMODE_3_SAMPLES | CAN_CTRLMODE_LISTENONLY,
.clock = {
.freq = PCAN_UFD_CRYSTAL_HZ,
},
.bittiming_const = &pcan_usb_x6_const,
.data_bittiming_const = &pcan_usb_x6_data_const,
/* size of device private data */
.sizeof_dev_private = sizeof(struct pcan_usb_fd_device),
/* timestamps usage */
.ts_used_bits = 32,
.ts_period = 1000000, /* calibration period in ts. */
.us_per_ts_scale = 1, /* us = (ts * scale) >> shift */
.us_per_ts_shift = 0,
/* give here messages in/out endpoints */
.ep_msg_in = PCAN_USBPRO_EP_MSGIN,
.ep_msg_out = {PCAN_USBPRO_EP_MSGOUT_0, PCAN_USBPRO_EP_MSGOUT_1},
/* size of rx/tx usb buffers */
.rx_buffer_size = PCAN_UFD_RX_BUFFER_SIZE,
.tx_buffer_size = PCAN_UFD_TX_BUFFER_SIZE,
/* device callbacks */
.intf_probe = pcan_usb_pro_probe, /* same as PCAN-USB Pro */
.dev_init = pcan_usb_fd_init,
.dev_exit = pcan_usb_fd_exit,
.dev_free = pcan_usb_fd_free,
.dev_set_bus = pcan_usb_fd_set_bus,
.dev_set_bittiming = pcan_usb_fd_set_bittiming_slow,
.dev_set_data_bittiming = pcan_usb_fd_set_bittiming_fast,
.dev_decode_buf = pcan_usb_fd_decode_buf,
.dev_start = pcan_usb_fd_start,
.dev_stop = pcan_usb_fd_stop,
.dev_restart_async = pcan_usb_fd_restart_async,
.dev_encode_msg = pcan_usb_fd_encode_msg,
.do_get_berr_counter = pcan_usb_fd_get_berr_counter,
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment