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

Merge tag 'linux-can-next-for-5.10-20200921' of...

Merge tag 'linux-can-next-for-5.10-20200921' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next

Marc Kleine-Budde says:

====================
pull-request: can-next 2020-09-21

this is a pull request of 38 patches for net-next.

the first 5 patches are by Colin Ian King, Alexandre Belloni and me and they
fix various spelling mistakes.

The next patch is by me and fixes the indention in the CAN raw protocol
according to the kernel coding style.

Diego Elio Pettenò contributes two patches to fix dead links in CAN's Kconfig.

Masahiro Yamada's patch removes the "WITH Linux-syscall-note" from SPDX tag of
C files.

AThe next 4 patches are by me and target the CAN device infrastructure and add
error propagation and improve the output of various messages to ease driver
development and debugging.

YueHaibing's patch for the c_can driver removes an unused inline function.

Next follows another patch by Colin Ian King, which removes the unneeded
initialization of a variable in the mcba_usb driver.

A patch by me annotates a fallthrough in the mscan driver.

The ti_hecc driver is converted to use devm_platform_ioremap_resource_byname()
in a patch by Dejin Zheng.

Liu Shixin's patch converts the pcan_usb_pro driver to make use of
le32_add_cpu() instead of open coding it.

Wang Hai's patch for the peak_pciefd_main driver removes an unused makro.

Vaibhav Gupta's patch converts the pch_can driver to generic power management.

Stephane Grosjean improves the pcan_usb usb driver by first documenting the
commands sent to the device and by adding support of rxerr/txerr counters.

The next patch is by me and cleans up the Kconfig of the CAN SPI drivers.

The next 6 patches all target the mcp251x driver, they are by Timo Schlüßler,
Andy Shevchenko, Tim Harvey and me. They update the DT bindings documentation,
sort the include files alphabetically, add GPIO support, make use of the
readx_poll_timeout() helper, and add support for half duplex SPI-controllers.

Wolfram Sang contributes a patch to update the contact email address in the
mscan driver, while Zhang Changzhong updates the clock handling.

The next patch is by and updates the rx-offload infrastructure to support
callback less usage.

The last 6 patches add support for the mcp25xxfd CAN SPI driver. First the
dt-bindings are added by Oleksij Rempel, the regmap infrastructure and the main
driver is contributed by me. Kurt Van Dijck adds listen-only support,
Manivannan Sadhasivam adds himself as maintainer, and Thomas Kopp himself as a
reviewer.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents ae4dd9a8 64fb587c
...@@ -12,6 +12,9 @@ Required properties: ...@@ -12,6 +12,9 @@ Required properties:
Optional properties: Optional properties:
- vdd-supply: Regulator that powers the CAN controller. - vdd-supply: Regulator that powers the CAN controller.
- xceiver-supply: Regulator that powers the CAN transceiver. - xceiver-supply: Regulator that powers the CAN transceiver.
- gpio-controller: Indicates this device is a GPIO controller.
- #gpio-cells: Should be two. The first cell is the pin number and
the second cell is used to specify the gpio polarity.
Example: Example:
can0: can@1 { can0: can@1 {
...@@ -19,7 +22,9 @@ Example: ...@@ -19,7 +22,9 @@ Example:
reg = <1>; reg = <1>;
clocks = <&clk24m>; clocks = <&clk24m>;
interrupt-parent = <&gpio4>; interrupt-parent = <&gpio4>;
interrupts = <13 0x2>; interrupts = <13 IRQ_TYPE_LEVEL_LOW>;
vdd-supply = <&reg5v0>; vdd-supply = <&reg5v0>;
xceiver-supply = <&reg5v0>; xceiver-supply = <&reg5v0>;
gpio-controller;
#gpio-cells = <2>;
}; };
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/net/can/microchip,mcp25xxfd.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title:
Microchip MCP2517FD and MCP2518FD stand-alone CAN controller device tree
bindings
maintainers:
- Marc Kleine-Budde <mkl@pengutronix.de>
properties:
compatible:
oneOf:
- const: microchip,mcp2517fd
description: for MCP2517FD
- const: microchip,mcp2518fd
description: for MCP2518FD
- const: microchip,mcp25xxfd
description: to autodetect chip variant
reg:
maxItems: 1
interrupts-extended:
maxItems: 1
clocks:
maxItems: 1
vdd-supply:
description: Regulator that powers the CAN controller.
maxItems: 1
xceiver-supply:
description: Regulator that powers the CAN transceiver.
maxItems: 1
microchip,rx-int-gpios:
description:
GPIO phandle of GPIO connected to to INT1 pin of the MCP25XXFD, which
signals a pending RX interrupt.
maxItems: 1
spi-max-frequency:
description:
Must be half or less of "clocks" frequency.
maximum: 20000000
required:
- compatible
- reg
- interrupts-extended
- clocks
examples:
- |
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/interrupt-controller/irq.h>
spi0 {
#address-cells = <1>;
#size-cells = <0>;
can@0 {
compatible = "microchip,mcp25xxfd";
reg = <0>;
clocks = <&can0_osc>;
pinctrl-names = "default";
pinctrl-0 = <&can0_pins>;
spi-max-frequency = <20000000>;
interrupts-extended = <&gpio 13 IRQ_TYPE_LEVEL_LOW>;
microchip,rx-int-gpios = <&gpio 27 GPIO_ACTIVE_LOW>;
vdd-supply = <&reg5v0>;
xceiver-supply = <&reg5v0>;
};
};
...@@ -10671,6 +10671,15 @@ L: linux-input@vger.kernel.org ...@@ -10671,6 +10671,15 @@ L: linux-input@vger.kernel.org
S: Maintained S: Maintained
F: drivers/hid/hid-mcp2221.c F: drivers/hid/hid-mcp2221.c
MCP25XXFD SPI-CAN NETWORK DRIVER
M: Marc Kleine-Budde <mkl@pengutronix.de>
M: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
R: Thomas Kopp <thomas.kopp@microchip.com>
L: linux-can@vger.kernel.org
S: Maintained
F: Documentation/devicetree/bindings/net/can/microchip,mcp25xxfd.yaml
F: drivers/net/can/spi/mcp25xxfd/
MCP4018 AND MCP4531 MICROCHIP DIGITAL POTENTIOMETER DRIVERS MCP4018 AND MCP4531 MICROCHIP DIGITAL POTENTIOMETER DRIVERS
M: Peter Rosin <peda@axentia.se> M: Peter Rosin <peda@axentia.se>
L: linux-iio@vger.kernel.org L: linux-iio@vger.kernel.org
......
...@@ -41,8 +41,8 @@ config CAN_SLCAN ...@@ -41,8 +41,8 @@ config CAN_SLCAN
www.canusb.com / www.can232.com / www.mictronics.de / www.canhack.de www.canusb.com / www.can232.com / www.mictronics.de / www.canhack.de
Userspace tools to attach the SLCAN line discipline (slcan_attach, Userspace tools to attach the SLCAN line discipline (slcan_attach,
slcand) can be found in the can-utils at the SocketCAN SVN, see slcand) can be found in the can-utils at the linux-can project, see
http://developer.berlios.de/projects/socketcan for details. https://github.com/linux-can/can-utils for details.
The slcan driver supports up to 10 CAN netdevices by default which The slcan driver supports up to 10 CAN netdevices by default which
can be changed by the 'maxdev=xx' module option. This driver can can be changed by the 'maxdev=xx' module option. This driver can
......
...@@ -643,7 +643,7 @@ static void at91_read_msg(struct net_device *dev, unsigned int mb) ...@@ -643,7 +643,7 @@ static void at91_read_msg(struct net_device *dev, unsigned int mb)
* *
* The first message goes into mb nr. 1 and issues an interrupt. All * The first message goes into mb nr. 1 and issues an interrupt. All
* rx ints are disabled in the interrupt handler and a napi poll is * rx ints are disabled in the interrupt handler and a napi poll is
* scheduled. We read the mailbox, but do _not_ reenable the mb (to * scheduled. We read the mailbox, but do _not_ re-enable the mb (to
* receive another message). * receive another message).
* *
* lower mbxs upper * lower mbxs upper
...@@ -661,13 +661,13 @@ static void at91_read_msg(struct net_device *dev, unsigned int mb) ...@@ -661,13 +661,13 @@ static void at91_read_msg(struct net_device *dev, unsigned int mb)
* *
* The variable priv->rx_next points to the next mailbox to read a * The variable priv->rx_next points to the next mailbox to read a
* message from. As long we're in the lower mailboxes we just read the * message from. As long we're in the lower mailboxes we just read the
* mailbox but not reenable it. * mailbox but not re-enable it.
* *
* With completion of the last of the lower mailboxes, we reenable the * With completion of the last of the lower mailboxes, we re-enable the
* whole first group, but continue to look for filled mailboxes in the * whole first group, but continue to look for filled mailboxes in the
* upper mailboxes. Imagine the second group like overflow mailboxes, * upper mailboxes. Imagine the second group like overflow mailboxes,
* which takes CAN messages if the lower goup is full. While in the * which takes CAN messages if the lower goup is full. While in the
* upper group we reenable the mailbox right after reading it. Giving * upper group we re-enable the mailbox right after reading it. Giving
* the chip more room to store messages. * the chip more room to store messages.
* *
* After finishing we look again in the lower group if we've still * After finishing we look again in the lower group if we've still
......
...@@ -356,15 +356,6 @@ static void c_can_setup_tx_object(struct net_device *dev, int iface, ...@@ -356,15 +356,6 @@ static void c_can_setup_tx_object(struct net_device *dev, int iface,
} }
} }
static inline void c_can_activate_all_lower_rx_msg_obj(struct net_device *dev,
int iface)
{
int i;
for (i = C_CAN_MSG_OBJ_RX_FIRST; i <= C_CAN_MSG_RX_LOW_LAST; i++)
c_can_object_get(dev, iface, i, IF_COMM_CLR_NEWDAT);
}
static int c_can_handle_lost_msg_obj(struct net_device *dev, static int c_can_handle_lost_msg_obj(struct net_device *dev,
int iface, int objno, u32 ctrl) int iface, int objno, u32 ctrl)
{ {
......
...@@ -538,7 +538,7 @@ static int cc770_err(struct net_device *dev, u8 status) ...@@ -538,7 +538,7 @@ static int cc770_err(struct net_device *dev, u8 status)
priv->can.can_stats.error_warning++; priv->can.can_stats.error_warning++;
} }
} else { } else {
/* Back to error avtive */ /* Back to error active */
cf->can_id |= CAN_ERR_PROT; cf->can_id |= CAN_ERR_PROT;
cf->data[2] = CAN_ERR_PROT_ACTIVE; cf->data[2] = CAN_ERR_PROT_ACTIVE;
priv->can.state = CAN_STATE_ERROR_ACTIVE; priv->can.state = CAN_STATE_ERROR_ACTIVE;
......
...@@ -184,7 +184,7 @@ struct cc770_priv { ...@@ -184,7 +184,7 @@ struct cc770_priv {
u8 control_normal_mode; /* Control register for normal mode */ u8 control_normal_mode; /* Control register for normal mode */
u8 cpu_interface; /* CPU interface register */ u8 cpu_interface; /* CPU interface register */
u8 clkout; /* Clock out register */ u8 clkout; /* Clock out register */
u8 bus_config; /* Bus conffiguration register */ u8 bus_config; /* Bus configuration register */
struct sk_buff *tx_skb; struct sk_buff *tx_skb;
}; };
......
...@@ -371,6 +371,28 @@ static int can_rx_state_to_frame(struct net_device *dev, enum can_state state) ...@@ -371,6 +371,28 @@ static int can_rx_state_to_frame(struct net_device *dev, enum can_state state)
} }
} }
static const char *can_get_state_str(const enum can_state state)
{
switch (state) {
case CAN_STATE_ERROR_ACTIVE:
return "Error Active";
case CAN_STATE_ERROR_WARNING:
return "Error Warning";
case CAN_STATE_ERROR_PASSIVE:
return "Error Passive";
case CAN_STATE_BUS_OFF:
return "Bus Off";
case CAN_STATE_STOPPED:
return "Stopped";
case CAN_STATE_SLEEPING:
return "Sleeping";
default:
return "<unknown>";
}
return "<unknown>";
}
void can_change_state(struct net_device *dev, struct can_frame *cf, void can_change_state(struct net_device *dev, struct can_frame *cf,
enum can_state tx_state, enum can_state rx_state) enum can_state tx_state, enum can_state rx_state)
{ {
...@@ -382,7 +404,9 @@ void can_change_state(struct net_device *dev, struct can_frame *cf, ...@@ -382,7 +404,9 @@ void can_change_state(struct net_device *dev, struct can_frame *cf,
return; return;
} }
netdev_dbg(dev, "New error state: %d\n", new_state); netdev_dbg(dev, "Controller changed from %s State (%d) into %s State (%d).\n",
can_get_state_str(priv->state), priv->state,
can_get_state_str(new_state), new_state);
can_update_state_error_stats(dev, new_state); can_update_state_error_stats(dev, new_state);
priv->state = new_state; priv->state = new_state;
...@@ -434,8 +458,8 @@ static void can_flush_echo_skb(struct net_device *dev) ...@@ -434,8 +458,8 @@ static void can_flush_echo_skb(struct net_device *dev)
* of the device driver. The driver must protect access to * of the device driver. The driver must protect access to
* priv->echo_skb, if necessary. * priv->echo_skb, if necessary.
*/ */
void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, int can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
unsigned int idx) unsigned int idx)
{ {
struct can_priv *priv = netdev_priv(dev); struct can_priv *priv = netdev_priv(dev);
...@@ -446,13 +470,13 @@ void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, ...@@ -446,13 +470,13 @@ void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
(skb->protocol != htons(ETH_P_CAN) && (skb->protocol != htons(ETH_P_CAN) &&
skb->protocol != htons(ETH_P_CANFD))) { skb->protocol != htons(ETH_P_CANFD))) {
kfree_skb(skb); kfree_skb(skb);
return; return 0;
} }
if (!priv->echo_skb[idx]) { if (!priv->echo_skb[idx]) {
skb = can_create_echo_skb(skb); skb = can_create_echo_skb(skb);
if (!skb) if (!skb)
return; return -ENOMEM;
/* make settings for echo to reduce code in irq context */ /* make settings for echo to reduce code in irq context */
skb->pkt_type = PACKET_BROADCAST; skb->pkt_type = PACKET_BROADCAST;
...@@ -463,9 +487,12 @@ void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, ...@@ -463,9 +487,12 @@ void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
priv->echo_skb[idx] = skb; priv->echo_skb[idx] = skb;
} else { } else {
/* locking problem with netif_stop_queue() ?? */ /* locking problem with netif_stop_queue() ?? */
netdev_err(dev, "%s: BUG! echo_skb is occupied!\n", __func__); netdev_err(dev, "%s: BUG! echo_skb %d is occupied!\n", __func__, idx);
kfree_skb(skb); kfree_skb(skb);
return -EBUSY;
} }
return 0;
} }
EXPORT_SYMBOL_GPL(can_put_echo_skb); EXPORT_SYMBOL_GPL(can_put_echo_skb);
...@@ -612,7 +639,11 @@ void can_bus_off(struct net_device *dev) ...@@ -612,7 +639,11 @@ void can_bus_off(struct net_device *dev)
{ {
struct can_priv *priv = netdev_priv(dev); struct can_priv *priv = netdev_priv(dev);
netdev_info(dev, "bus-off\n"); if (priv->restart_ms)
netdev_info(dev, "bus-off, scheduling restart in %d ms\n",
priv->restart_ms);
else
netdev_info(dev, "bus-off\n");
netif_carrier_off(dev); netif_carrier_off(dev);
......
...@@ -230,7 +230,7 @@ struct flexcan_regs { ...@@ -230,7 +230,7 @@ struct flexcan_regs {
/* FIFO-mode: /* FIFO-mode:
* MB * MB
* 0x080...0x08f 0 RX message buffer * 0x080...0x08f 0 RX message buffer
* 0x090...0x0df 1-5 reserverd * 0x090...0x0df 1-5 reserved
* 0x0e0...0x0ff 6-7 8 entry ID table * 0x0e0...0x0ff 6-7 8 entry ID table
* (mx25, mx28, mx35, mx53) * (mx25, mx28, mx35, mx53)
* 0x0e0...0x2df 6-7..37 8..128 entry ID table * 0x0e0...0x2df 6-7..37 8..128 entry ID table
......
...@@ -726,7 +726,7 @@ static void grcan_err(struct net_device *dev, u32 sources, u32 status) ...@@ -726,7 +726,7 @@ static void grcan_err(struct net_device *dev, u32 sources, u32 status)
txrx = "on rx "; txrx = "on rx ";
stats->rx_errors++; stats->rx_errors++;
} }
netdev_err(dev, "Fatal AHB buss error %s- halting device\n", netdev_err(dev, "Fatal AHB bus error %s- halting device\n",
txrx); txrx);
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
...@@ -1243,7 +1243,7 @@ static int grcan_poll(struct napi_struct *napi, int budget) ...@@ -1243,7 +1243,7 @@ static int grcan_poll(struct napi_struct *napi, int budget)
int rx_budget = budget / 2; int rx_budget = budget / 2;
int tx_budget = budget - rx_budget; int tx_budget = budget - rx_budget;
/* Half of the budget for receiveing messages */ /* Half of the budget for receiving messages */
rx_work_done = grcan_receive(dev, rx_budget); rx_work_done = grcan_receive(dev, rx_budget);
/* Half of the budget for transmitting messages as that can trigger echo /* Half of the budget for transmitting messages as that can trigger echo
......
...@@ -20,5 +20,5 @@ config CAN_M_CAN_TCAN4X5X ...@@ -20,5 +20,5 @@ config CAN_M_CAN_TCAN4X5X
tristate "TCAN4X5X M_CAN device" tristate "TCAN4X5X M_CAN device"
help help
Say Y here if you want support for Texas Instruments TCAN4x5x Say Y here if you want support for Texas Instruments TCAN4x5x
M_CAN controller. This device is a peripherial device that uses the M_CAN controller. This device is a peripheral device that uses the
SPI bus for communication. SPI bus for communication.
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Copyright (C) 2004-2005 Andrey Volkov <avolkov@varma-el.com>, * Copyright (C) 2004-2005 Andrey Volkov <avolkov@varma-el.com>,
* Varma Electronics Oy * Varma Electronics Oy
* Copyright (C) 2008-2009 Wolfgang Grandegger <wg@grandegger.com> * Copyright (C) 2008-2009 Wolfgang Grandegger <wg@grandegger.com>
* Copyright (C) 2009 Wolfram Sang, Pengutronix <w.sang@pengutronix.de> * Copyright (C) 2009 Wolfram Sang, Pengutronix <kernel@pengutronix.de>
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
......
...@@ -209,6 +209,7 @@ static netdev_tx_t mscan_start_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -209,6 +209,7 @@ static netdev_tx_t mscan_start_xmit(struct sk_buff *skb, struct net_device *dev)
* since buffer with lower id have higher priority (hell..) * since buffer with lower id have higher priority (hell..)
*/ */
netif_stop_queue(dev); netif_stop_queue(dev);
fallthrough;
case 2: case 2:
if (buf_id < priv->prev_buf_id) { if (buf_id < priv->prev_buf_id) {
priv->cur_pri++; priv->cur_pri++;
...@@ -540,16 +541,12 @@ static int mscan_open(struct net_device *dev) ...@@ -540,16 +541,12 @@ static int mscan_open(struct net_device *dev)
struct mscan_priv *priv = netdev_priv(dev); struct mscan_priv *priv = netdev_priv(dev);
struct mscan_regs __iomem *regs = priv->reg_base; struct mscan_regs __iomem *regs = priv->reg_base;
if (priv->clk_ipg) { ret = clk_prepare_enable(priv->clk_ipg);
ret = clk_prepare_enable(priv->clk_ipg); if (ret)
if (ret) goto exit_retcode;
goto exit_retcode; ret = clk_prepare_enable(priv->clk_can);
} if (ret)
if (priv->clk_can) { goto exit_dis_ipg_clock;
ret = clk_prepare_enable(priv->clk_can);
if (ret)
goto exit_dis_ipg_clock;
}
/* common open */ /* common open */
ret = open_candev(dev); ret = open_candev(dev);
...@@ -583,11 +580,9 @@ static int mscan_open(struct net_device *dev) ...@@ -583,11 +580,9 @@ static int mscan_open(struct net_device *dev)
napi_disable(&priv->napi); napi_disable(&priv->napi);
close_candev(dev); close_candev(dev);
exit_dis_can_clock: exit_dis_can_clock:
if (priv->clk_can) clk_disable_unprepare(priv->clk_can);
clk_disable_unprepare(priv->clk_can);
exit_dis_ipg_clock: exit_dis_ipg_clock:
if (priv->clk_ipg) clk_disable_unprepare(priv->clk_ipg);
clk_disable_unprepare(priv->clk_ipg);
exit_retcode: exit_retcode:
return ret; return ret;
} }
...@@ -606,10 +601,8 @@ static int mscan_close(struct net_device *dev) ...@@ -606,10 +601,8 @@ static int mscan_close(struct net_device *dev)
close_candev(dev); close_candev(dev);
free_irq(dev->irq, dev); free_irq(dev->irq, dev);
if (priv->clk_can) clk_disable_unprepare(priv->clk_can);
clk_disable_unprepare(priv->clk_can); clk_disable_unprepare(priv->clk_ipg);
if (priv->clk_ipg)
clk_disable_unprepare(priv->clk_ipg);
return 0; return 0;
} }
......
...@@ -461,7 +461,7 @@ static void pch_can_int_clr(struct pch_can_priv *priv, u32 mask) ...@@ -461,7 +461,7 @@ static void pch_can_int_clr(struct pch_can_priv *priv, u32 mask)
PCH_ID2_DIR | (0x7ff << 2)); PCH_ID2_DIR | (0x7ff << 2));
iowrite32(0x0, &priv->regs->ifregs[1].id1); iowrite32(0x0, &priv->regs->ifregs[1].id1);
/* Claring NewDat, TxRqst & IntPnd */ /* Clearing NewDat, TxRqst & IntPnd */
pch_can_bit_clear(&priv->regs->ifregs[1].mcont, pch_can_bit_clear(&priv->regs->ifregs[1].mcont,
PCH_IF_MCONT_NEWDAT | PCH_IF_MCONT_INTPND | PCH_IF_MCONT_NEWDAT | PCH_IF_MCONT_INTPND |
PCH_IF_MCONT_TXRQXT); PCH_IF_MCONT_TXRQXT);
...@@ -834,7 +834,7 @@ static int pch_can_open(struct net_device *ndev) ...@@ -834,7 +834,7 @@ static int pch_can_open(struct net_device *ndev)
struct pch_can_priv *priv = netdev_priv(ndev); struct pch_can_priv *priv = netdev_priv(ndev);
int retval; int retval;
/* Regstering the interrupt. */ /* Registering the interrupt. */
retval = request_irq(priv->dev->irq, pch_can_interrupt, IRQF_SHARED, retval = request_irq(priv->dev->irq, pch_can_interrupt, IRQF_SHARED,
ndev->name, ndev); ndev->name, ndev);
if (retval) { if (retval) {
...@@ -957,8 +957,7 @@ static void pch_can_remove(struct pci_dev *pdev) ...@@ -957,8 +957,7 @@ static void pch_can_remove(struct pci_dev *pdev)
free_candev(priv->ndev); free_candev(priv->ndev);
} }
#ifdef CONFIG_PM static void __maybe_unused pch_can_set_int_custom(struct pch_can_priv *priv)
static void pch_can_set_int_custom(struct pch_can_priv *priv)
{ {
/* Clearing the IE, SIE and EIE bits of Can control register. */ /* Clearing the IE, SIE and EIE bits of Can control register. */
pch_can_bit_clear(&priv->regs->cont, PCH_CTRL_IE_SIE_EIE); pch_can_bit_clear(&priv->regs->cont, PCH_CTRL_IE_SIE_EIE);
...@@ -969,14 +968,14 @@ static void pch_can_set_int_custom(struct pch_can_priv *priv) ...@@ -969,14 +968,14 @@ static void pch_can_set_int_custom(struct pch_can_priv *priv)
} }
/* This function retrieves interrupt enabled for the CAN device. */ /* This function retrieves interrupt enabled for the CAN device. */
static u32 pch_can_get_int_enables(struct pch_can_priv *priv) static u32 __maybe_unused pch_can_get_int_enables(struct pch_can_priv *priv)
{ {
/* Obtaining the status of IE, SIE and EIE interrupt bits. */ /* Obtaining the status of IE, SIE and EIE interrupt bits. */
return (ioread32(&priv->regs->cont) & PCH_CTRL_IE_SIE_EIE) >> 1; return (ioread32(&priv->regs->cont) & PCH_CTRL_IE_SIE_EIE) >> 1;
} }
static u32 pch_can_get_rxtx_ir(struct pch_can_priv *priv, u32 buff_num, static u32 __maybe_unused pch_can_get_rxtx_ir(struct pch_can_priv *priv,
enum pch_ifreg dir) u32 buff_num, enum pch_ifreg dir)
{ {
u32 ie, enable; u32 ie, enable;
...@@ -997,8 +996,8 @@ static u32 pch_can_get_rxtx_ir(struct pch_can_priv *priv, u32 buff_num, ...@@ -997,8 +996,8 @@ static u32 pch_can_get_rxtx_ir(struct pch_can_priv *priv, u32 buff_num,
return enable; return enable;
} }
static void pch_can_set_rx_buffer_link(struct pch_can_priv *priv, static void __maybe_unused pch_can_set_rx_buffer_link(struct pch_can_priv *priv,
u32 buffer_num, int set) u32 buffer_num, int set)
{ {
iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->ifregs[0].cmask); iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->ifregs[0].cmask);
pch_can_rw_msg_obj(&priv->regs->ifregs[0].creq, buffer_num); pch_can_rw_msg_obj(&priv->regs->ifregs[0].creq, buffer_num);
...@@ -1013,7 +1012,8 @@ static void pch_can_set_rx_buffer_link(struct pch_can_priv *priv, ...@@ -1013,7 +1012,8 @@ static void pch_can_set_rx_buffer_link(struct pch_can_priv *priv,
pch_can_rw_msg_obj(&priv->regs->ifregs[0].creq, buffer_num); pch_can_rw_msg_obj(&priv->regs->ifregs[0].creq, buffer_num);
} }
static u32 pch_can_get_rx_buffer_link(struct pch_can_priv *priv, u32 buffer_num) static u32 __maybe_unused pch_can_get_rx_buffer_link(struct pch_can_priv *priv,
u32 buffer_num)
{ {
u32 link; u32 link;
...@@ -1027,20 +1027,19 @@ static u32 pch_can_get_rx_buffer_link(struct pch_can_priv *priv, u32 buffer_num) ...@@ -1027,20 +1027,19 @@ static u32 pch_can_get_rx_buffer_link(struct pch_can_priv *priv, u32 buffer_num)
return link; return link;
} }
static int pch_can_get_buffer_status(struct pch_can_priv *priv) static int __maybe_unused pch_can_get_buffer_status(struct pch_can_priv *priv)
{ {
return (ioread32(&priv->regs->treq1) & 0xffff) | return (ioread32(&priv->regs->treq1) & 0xffff) |
(ioread32(&priv->regs->treq2) << 16); (ioread32(&priv->regs->treq2) << 16);
} }
static int pch_can_suspend(struct pci_dev *pdev, pm_message_t state) static int __maybe_unused pch_can_suspend(struct device *dev_d)
{ {
int i; int i;
int retval;
u32 buf_stat; /* Variable for reading the transmit buffer status. */ u32 buf_stat; /* Variable for reading the transmit buffer status. */
int counter = PCH_COUNTER_LIMIT; int counter = PCH_COUNTER_LIMIT;
struct net_device *dev = pci_get_drvdata(pdev); struct net_device *dev = dev_get_drvdata(dev_d);
struct pch_can_priv *priv = netdev_priv(dev); struct pch_can_priv *priv = netdev_priv(dev);
/* Stop the CAN controller */ /* Stop the CAN controller */
...@@ -1058,7 +1057,7 @@ static int pch_can_suspend(struct pci_dev *pdev, pm_message_t state) ...@@ -1058,7 +1057,7 @@ static int pch_can_suspend(struct pci_dev *pdev, pm_message_t state)
udelay(1); udelay(1);
} }
if (!counter) if (!counter)
dev_err(&pdev->dev, "%s -> Transmission time out.\n", __func__); dev_err(dev_d, "%s -> Transmission time out.\n", __func__);
/* Save interrupt configuration and then disable them */ /* Save interrupt configuration and then disable them */
priv->int_enables = pch_can_get_int_enables(priv); priv->int_enables = pch_can_get_int_enables(priv);
...@@ -1081,35 +1080,16 @@ static int pch_can_suspend(struct pci_dev *pdev, pm_message_t state) ...@@ -1081,35 +1080,16 @@ static int pch_can_suspend(struct pci_dev *pdev, pm_message_t state)
/* Disable all Receive buffers */ /* Disable all Receive buffers */
pch_can_set_rx_all(priv, 0); pch_can_set_rx_all(priv, 0);
retval = pci_save_state(pdev);
if (retval) {
dev_err(&pdev->dev, "pci_save_state failed.\n");
} else {
pci_enable_wake(pdev, PCI_D3hot, 0);
pci_disable_device(pdev);
pci_set_power_state(pdev, pci_choose_state(pdev, state));
}
return retval; return 0;
} }
static int pch_can_resume(struct pci_dev *pdev) static int __maybe_unused pch_can_resume(struct device *dev_d)
{ {
int i; int i;
int retval; struct net_device *dev = dev_get_drvdata(dev_d);
struct net_device *dev = pci_get_drvdata(pdev);
struct pch_can_priv *priv = netdev_priv(dev); struct pch_can_priv *priv = netdev_priv(dev);
pci_set_power_state(pdev, PCI_D0);
pci_restore_state(pdev);
retval = pci_enable_device(pdev);
if (retval) {
dev_err(&pdev->dev, "pci_enable_device failed.\n");
return retval;
}
pci_enable_wake(pdev, PCI_D3hot, 0);
priv->can.state = CAN_STATE_ERROR_ACTIVE; priv->can.state = CAN_STATE_ERROR_ACTIVE;
/* Disabling all interrupts. */ /* Disabling all interrupts. */
...@@ -1146,12 +1126,8 @@ static int pch_can_resume(struct pci_dev *pdev) ...@@ -1146,12 +1126,8 @@ static int pch_can_resume(struct pci_dev *pdev)
/* Restore Run Mode */ /* Restore Run Mode */
pch_can_set_run_mode(priv, PCH_CAN_RUN); pch_can_set_run_mode(priv, PCH_CAN_RUN);
return retval; return 0;
} }
#else
#define pch_can_suspend NULL
#define pch_can_resume NULL
#endif
static int pch_can_get_berr_counter(const struct net_device *dev, static int pch_can_get_berr_counter(const struct net_device *dev,
struct can_berr_counter *bec) struct can_berr_counter *bec)
...@@ -1252,13 +1228,16 @@ static int pch_can_probe(struct pci_dev *pdev, ...@@ -1252,13 +1228,16 @@ static int pch_can_probe(struct pci_dev *pdev,
return rc; return rc;
} }
static SIMPLE_DEV_PM_OPS(pch_can_pm_ops,
pch_can_suspend,
pch_can_resume);
static struct pci_driver pch_can_pci_driver = { static struct pci_driver pch_can_pci_driver = {
.name = "pch_can", .name = "pch_can",
.id_table = pch_pci_tbl, .id_table = pch_pci_tbl,
.probe = pch_can_probe, .probe = pch_can_probe,
.remove = pch_can_remove, .remove = pch_can_remove,
.suspend = pch_can_suspend, .driver.pm = &pch_can_pm_ops,
.resume = pch_can_resume,
}; };
module_pci_driver(pch_can_pci_driver); module_pci_driver(pch_can_pci_driver);
......
...@@ -116,8 +116,6 @@ MODULE_LICENSE("GPL v2"); ...@@ -116,8 +116,6 @@ MODULE_LICENSE("GPL v2");
#define CANFD_CTL_IRQ_CL_DEF 16 /* Rx msg max nb per IRQ in Rx DMA */ #define CANFD_CTL_IRQ_CL_DEF 16 /* Rx msg max nb per IRQ in Rx DMA */
#define CANFD_CTL_IRQ_TL_DEF 10 /* Time before IRQ if < CL (x100 µs) */ #define CANFD_CTL_IRQ_TL_DEF 10 /* Time before IRQ if < CL (x100 µs) */
#define CANFD_OPTIONS_SET (CANFD_OPTION_ERROR | CANFD_OPTION_BUSLOAD)
/* Tx anticipation window (link logical address should be aligned on 2K /* Tx anticipation window (link logical address should be aligned on 2K
* boundary) * boundary)
*/ */
......
...@@ -351,6 +351,17 @@ int can_rx_offload_add_fifo(struct net_device *dev, ...@@ -351,6 +351,17 @@ int can_rx_offload_add_fifo(struct net_device *dev,
} }
EXPORT_SYMBOL_GPL(can_rx_offload_add_fifo); EXPORT_SYMBOL_GPL(can_rx_offload_add_fifo);
int can_rx_offload_add_manual(struct net_device *dev,
struct can_rx_offload *offload,
unsigned int weight)
{
if (offload->mailbox_read)
return -EINVAL;
return can_rx_offload_init_queue(dev, offload, weight);
}
EXPORT_SYMBOL_GPL(can_rx_offload_add_manual);
void can_rx_offload_enable(struct can_rx_offload *offload) void can_rx_offload_enable(struct can_rx_offload *offload)
{ {
napi_enable(&offload->napi); napi_enable(&offload->napi);
......
...@@ -97,7 +97,7 @@ MODULE_DEVICE_TABLE(pci, peak_pci_tbl); ...@@ -97,7 +97,7 @@ MODULE_DEVICE_TABLE(pci, peak_pci_tbl);
/* GPIOICR byte access offsets */ /* GPIOICR byte access offsets */
#define PITA_GPOUT 0x18 /* GPx output value */ #define PITA_GPOUT 0x18 /* GPx output value */
#define PITA_GPIN 0x19 /* GPx input value */ #define PITA_GPIN 0x19 /* GPx input value */
#define PITA_GPOEN 0x1A /* configure GPx as ouput pin */ #define PITA_GPOEN 0x1A /* configure GPx as output pin */
/* I2C GP bits */ /* I2C GP bits */
#define PITA_GPIN_SCL 0x01 /* Serial Clock Line */ #define PITA_GPIN_SCL 0x01 /* Serial Clock Line */
......
...@@ -671,7 +671,7 @@ static int pcan_probe(struct pcmcia_device *pdev) ...@@ -671,7 +671,7 @@ static int pcan_probe(struct pcmcia_device *pdev)
card->fw_major = pcan_read_reg(card, PCC_FW_MAJOR); card->fw_major = pcan_read_reg(card, PCC_FW_MAJOR);
card->fw_minor = pcan_read_reg(card, PCC_FW_MINOR); card->fw_minor = pcan_read_reg(card, PCC_FW_MINOR);
/* display board name and firware version */ /* display board name and firmware version */
dev_info(&pdev->dev, "PEAK-System pcmcia card %s fw %d.%d\n", dev_info(&pdev->dev, "PEAK-System pcmcia card %s fw %d.%d\n",
pdev->prod_id[1] ? pdev->prod_id[1] : "PCAN-PC Card", pdev->prod_id[1] ? pdev->prod_id[1] : "PCAN-PC Card",
card->fw_major, card->fw_minor); card->fw_major, card->fw_minor);
......
...@@ -5,14 +5,14 @@ config CAN_SOFTING ...@@ -5,14 +5,14 @@ config CAN_SOFTING
help help
Support for CAN cards from Softing Gmbh & some cards Support for CAN cards from Softing Gmbh & some cards
from Vector Gmbh. from Vector Gmbh.
Softing Gmbh CAN cards come with 1 or 2 physical busses. Softing Gmbh CAN cards come with 1 or 2 physical buses.
Those cards typically use Dual Port RAM to communicate Those cards typically use Dual Port RAM to communicate
with the host CPU. The interface is then identical for PCI with the host CPU. The interface is then identical for PCI
and PCMCIA cards. This driver operates on a platform device, and PCMCIA cards. This driver operates on a platform device,
which has been created by softing_cs or softing_pci driver. which has been created by softing_cs or softing_pci driver.
Warning: Warning:
The API of the card does not allow fine control per bus, but The API of the card does not allow fine control per bus, but
controls the 2 busses on the card together. controls the 2 buses on the card together.
As such, some actions (start/stop/busoff recovery) on 1 bus As such, some actions (start/stop/busoff recovery) on 1 bus
must bring down the other bus too temporarily. must bring down the other bus too temporarily.
...@@ -24,7 +24,7 @@ config CAN_SOFTING_CS ...@@ -24,7 +24,7 @@ config CAN_SOFTING_CS
Support for PCMCIA cards from Softing Gmbh & some cards Support for PCMCIA cards from Softing Gmbh & some cards
from Vector Gmbh. from Vector Gmbh.
You need firmware for these, which you can get at You need firmware for these, which you can get at
http://developer.berlios.de/projects/socketcan/ https://github.com/linux-can/can-firmware
This version of the driver is written against This version of the driver is written against
firmware version 4.6 (softing-fw-4.6-binaries.tar.gz) firmware version 4.6 (softing-fw-4.6-binaries.tar.gz)
In order to use the card as CAN device, you need the Softing generic In order to use the card as CAN device, you need the Softing generic
......
...@@ -273,7 +273,7 @@ int softing_load_app_fw(const char *file, struct softing *card) ...@@ -273,7 +273,7 @@ int softing_load_app_fw(const char *file, struct softing *card)
goto failed; goto failed;
} }
/* regualar data */ /* regular data */
for (sum = 0, j = 0; j < len; ++j) for (sum = 0, j = 0; j < len; ++j)
sum += dat[j]; sum += dat[j];
/* work in 16bit (target) */ /* work in 16bit (target) */
...@@ -474,14 +474,14 @@ int softing_startstop(struct net_device *dev, int up) ...@@ -474,14 +474,14 @@ int softing_startstop(struct net_device *dev, int up)
if (ret) if (ret)
goto failed; goto failed;
if (!bus_bitmask_start) if (!bus_bitmask_start)
/* no busses to be brought up */ /* no buses to be brought up */
goto card_done; goto card_done;
if ((bus_bitmask_start & 1) && (bus_bitmask_start & 2) if ((bus_bitmask_start & 1) && (bus_bitmask_start & 2)
&& (softing_error_reporting(card->net[0]) && (softing_error_reporting(card->net[0])
!= softing_error_reporting(card->net[1]))) { != softing_error_reporting(card->net[1]))) {
dev_alert(&card->pdev->dev, dev_alert(&card->pdev->dev,
"err_reporting flag differs for busses\n"); "err_reporting flag differs for buses\n");
goto invalid; goto invalid;
} }
error_reporting = 0; error_reporting = 0;
...@@ -635,7 +635,7 @@ int softing_startstop(struct net_device *dev, int up) ...@@ -635,7 +635,7 @@ int softing_startstop(struct net_device *dev, int up)
priv->can.state = CAN_STATE_ERROR_ACTIVE; priv->can.state = CAN_STATE_ERROR_ACTIVE;
open_candev(netdev); open_candev(netdev);
if (dev != netdev) { if (dev != netdev) {
/* notify other busses on the restart */ /* notify other buses on the restart */
softing_netdev_rx(netdev, &msg, 0); softing_netdev_rx(netdev, &msg, 0);
++priv->can.can_stats.restarts; ++priv->can.can_stats.restarts;
} }
......
...@@ -170,8 +170,8 @@ static int softing_handle_1(struct softing *card) ...@@ -170,8 +170,8 @@ static int softing_handle_1(struct softing *card)
msg.can_dlc = CAN_ERR_DLC; msg.can_dlc = CAN_ERR_DLC;
msg.data[1] = CAN_ERR_CRTL_RX_OVERFLOW; msg.data[1] = CAN_ERR_CRTL_RX_OVERFLOW;
/* /*
* service to all busses, we don't know which it was applicable * service to all buses, we don't know which it was applicable
* but only service busses that are online * but only service buses that are online
*/ */
for (j = 0; j < ARRAY_SIZE(card->net); ++j) { for (j = 0; j < ARRAY_SIZE(card->net); ++j) {
netdev = card->net[j]; netdev = card->net[j];
...@@ -339,7 +339,7 @@ static irqreturn_t softing_irq_thread(int irq, void *dev_id) ...@@ -339,7 +339,7 @@ static irqreturn_t softing_irq_thread(int irq, void *dev_id)
continue; continue;
priv = netdev_priv(netdev); priv = netdev_priv(netdev);
if (!canif_is_active(netdev)) if (!canif_is_active(netdev))
/* it makes no sense to wake dead busses */ /* it makes no sense to wake dead buses */
continue; continue;
if (priv->tx.pending >= TX_ECHO_SKB_MAX) if (priv->tx.pending >= TX_ECHO_SKB_MAX)
continue; continue;
...@@ -374,7 +374,7 @@ static irqreturn_t softing_irq_v1(int irq, void *dev_id) ...@@ -374,7 +374,7 @@ static irqreturn_t softing_irq_v1(int irq, void *dev_id)
} }
/* /*
* netdev/candev inter-operability * netdev/candev interoperability
*/ */
static int softing_netdev_open(struct net_device *ndev) static int softing_netdev_open(struct net_device *ndev)
{ {
......
...@@ -19,7 +19,7 @@ struct softing_platform_data { ...@@ -19,7 +19,7 @@ struct softing_platform_data {
* 16bit, shared interrupt * 16bit, shared interrupt
*/ */
int generation; int generation;
int nbus; /* # busses on device */ int nbus; /* # buses on device */
unsigned int freq; /* operating frequency in Hz */ unsigned int freq; /* operating frequency in Hz */
unsigned int max_brp; unsigned int max_brp;
unsigned int max_sjw; unsigned int max_sjw;
......
...@@ -4,15 +4,15 @@ menu "CAN SPI interfaces" ...@@ -4,15 +4,15 @@ menu "CAN SPI interfaces"
config CAN_HI311X config CAN_HI311X
tristate "Holt HI311x SPI CAN controllers" tristate "Holt HI311x SPI CAN controllers"
depends on CAN_DEV && SPI && HAS_DMA
help help
Driver for the Holt HI311x SPI CAN controllers. Driver for the Holt HI311x SPI CAN controllers.
config CAN_MCP251X config CAN_MCP251X
tristate "Microchip MCP251x and MCP25625 SPI CAN controllers" tristate "Microchip MCP251x and MCP25625 SPI CAN controllers"
depends on HAS_DMA
help help
Driver for the Microchip MCP251x and MCP25625 SPI CAN Driver for the Microchip MCP251x and MCP25625 SPI CAN
controllers. controllers.
source "drivers/net/can/spi/mcp25xxfd/Kconfig"
endmenu endmenu
...@@ -6,3 +6,4 @@ ...@@ -6,3 +6,4 @@
obj-$(CONFIG_CAN_HI311X) += hi311x.o obj-$(CONFIG_CAN_HI311X) += hi311x.o
obj-$(CONFIG_CAN_MCP251X) += mcp251x.o obj-$(CONFIG_CAN_MCP251X) += mcp251x.o
obj-y += mcp25xxfd/
This diff is collapsed.
# SPDX-License-Identifier: GPL-2.0-only
config CAN_MCP25XXFD
tristate "Microchip MCP25xxFD SPI CAN controllers"
select REGMAP
help
Driver for the Microchip MCP25XXFD SPI FD-CAN controller
family.
config CAN_MCP25XXFD_SANITY
depends on CAN_MCP25XXFD
bool "Additional Sanity Checks"
help
This option enables additional sanity checks in the driver,
that compares various internal counters with the in chip
variants. This comes with a runtime overhead.
Disable if unsure.
# SPDX-License-Identifier: GPL-2.0-only
obj-$(CONFIG_CAN_MCP25XXFD) += mcp25xxfd.o
mcp25xxfd-objs :=
mcp25xxfd-objs += mcp25xxfd-core.o
mcp25xxfd-objs += mcp25xxfd-crc16.o
mcp25xxfd-objs += mcp25xxfd-regmap.o
This diff is collapsed.
// SPDX-License-Identifier: GPL-2.0
//
// mcp25xxfd - Microchip MCP25xxFD Family CAN controller driver
//
// Copyright (c) 2020 Pengutronix,
// Marc Kleine-Budde <kernel@pengutronix.de>
//
// Based on:
//
// CAN bus driver for Microchip 25XXFD CAN Controller with SPI Interface
//
// Copyright (c) 2019 Martin Sperl <kernel@martin.sperl.org>
//
#include "mcp25xxfd.h"
/* The standard crc16 in linux/crc16.h is unfortunately not computing
* the correct results (left shift vs. right shift). So here an
* implementation with a table generated with the help of:
*
* http://lkml.iu.edu/hypermail/linux/kernel/0508.1/1085.html
*/
static const u16 mcp25xxfd_crc16_table[] = {
0x0000, 0x8005, 0x800f, 0x000a, 0x801b, 0x001e, 0x0014, 0x8011,
0x8033, 0x0036, 0x003c, 0x8039, 0x0028, 0x802d, 0x8027, 0x0022,
0x8063, 0x0066, 0x006c, 0x8069, 0x0078, 0x807d, 0x8077, 0x0072,
0x0050, 0x8055, 0x805f, 0x005a, 0x804b, 0x004e, 0x0044, 0x8041,
0x80c3, 0x00c6, 0x00cc, 0x80c9, 0x00d8, 0x80dd, 0x80d7, 0x00d2,
0x00f0, 0x80f5, 0x80ff, 0x00fa, 0x80eb, 0x00ee, 0x00e4, 0x80e1,
0x00a0, 0x80a5, 0x80af, 0x00aa, 0x80bb, 0x00be, 0x00b4, 0x80b1,
0x8093, 0x0096, 0x009c, 0x8099, 0x0088, 0x808d, 0x8087, 0x0082,
0x8183, 0x0186, 0x018c, 0x8189, 0x0198, 0x819d, 0x8197, 0x0192,
0x01b0, 0x81b5, 0x81bf, 0x01ba, 0x81ab, 0x01ae, 0x01a4, 0x81a1,
0x01e0, 0x81e5, 0x81ef, 0x01ea, 0x81fb, 0x01fe, 0x01f4, 0x81f1,
0x81d3, 0x01d6, 0x01dc, 0x81d9, 0x01c8, 0x81cd, 0x81c7, 0x01c2,
0x0140, 0x8145, 0x814f, 0x014a, 0x815b, 0x015e, 0x0154, 0x8151,
0x8173, 0x0176, 0x017c, 0x8179, 0x0168, 0x816d, 0x8167, 0x0162,
0x8123, 0x0126, 0x012c, 0x8129, 0x0138, 0x813d, 0x8137, 0x0132,
0x0110, 0x8115, 0x811f, 0x011a, 0x810b, 0x010e, 0x0104, 0x8101,
0x8303, 0x0306, 0x030c, 0x8309, 0x0318, 0x831d, 0x8317, 0x0312,
0x0330, 0x8335, 0x833f, 0x033a, 0x832b, 0x032e, 0x0324, 0x8321,
0x0360, 0x8365, 0x836f, 0x036a, 0x837b, 0x037e, 0x0374, 0x8371,
0x8353, 0x0356, 0x035c, 0x8359, 0x0348, 0x834d, 0x8347, 0x0342,
0x03c0, 0x83c5, 0x83cf, 0x03ca, 0x83db, 0x03de, 0x03d4, 0x83d1,
0x83f3, 0x03f6, 0x03fc, 0x83f9, 0x03e8, 0x83ed, 0x83e7, 0x03e2,
0x83a3, 0x03a6, 0x03ac, 0x83a9, 0x03b8, 0x83bd, 0x83b7, 0x03b2,
0x0390, 0x8395, 0x839f, 0x039a, 0x838b, 0x038e, 0x0384, 0x8381,
0x0280, 0x8285, 0x828f, 0x028a, 0x829b, 0x029e, 0x0294, 0x8291,
0x82b3, 0x02b6, 0x02bc, 0x82b9, 0x02a8, 0x82ad, 0x82a7, 0x02a2,
0x82e3, 0x02e6, 0x02ec, 0x82e9, 0x02f8, 0x82fd, 0x82f7, 0x02f2,
0x02d0, 0x82d5, 0x82df, 0x02da, 0x82cb, 0x02ce, 0x02c4, 0x82c1,
0x8243, 0x0246, 0x024c, 0x8249, 0x0258, 0x825d, 0x8257, 0x0252,
0x0270, 0x8275, 0x827f, 0x027a, 0x826b, 0x026e, 0x0264, 0x8261,
0x0220, 0x8225, 0x822f, 0x022a, 0x823b, 0x023e, 0x0234, 0x8231,
0x8213, 0x0216, 0x021c, 0x8219, 0x0208, 0x820d, 0x8207, 0x0202
};
static inline u16 mcp25xxfd_crc16_byte(u16 crc, const u8 data)
{
u8 index = (crc >> 8) ^ data;
return (crc << 8) ^ mcp25xxfd_crc16_table[index];
}
static u16 mcp25xxfd_crc16(u16 crc, u8 const *buffer, size_t len)
{
while (len--)
crc = mcp25xxfd_crc16_byte(crc, *buffer++);
return crc;
}
u16 mcp25xxfd_crc16_compute(const void *data, size_t data_size)
{
u16 crc = 0xffff;
return mcp25xxfd_crc16(crc, data, data_size);
}
u16 mcp25xxfd_crc16_compute2(const void *cmd, size_t cmd_size,
const void *data, size_t data_size)
{
u16 crc;
crc = mcp25xxfd_crc16_compute(cmd, cmd_size);
crc = mcp25xxfd_crc16(crc, data, data_size);
return crc;
}
This diff is collapsed.
This diff is collapsed.
...@@ -454,7 +454,7 @@ static int ti_hecc_get_berr_counter(const struct net_device *ndev, ...@@ -454,7 +454,7 @@ static int ti_hecc_get_berr_counter(const struct net_device *ndev,
/* ti_hecc_xmit: HECC Transmit /* ti_hecc_xmit: HECC Transmit
* *
* The transmit mailboxes start from 0 to HECC_MAX_TX_MBOX. In HECC the * The transmit mailboxes start from 0 to HECC_MAX_TX_MBOX. In HECC the
* priority of the mailbox for tranmission is dependent upon priority setting * priority of the mailbox for transmission is dependent upon priority setting
* field in mailbox registers. The mailbox with highest value in priority field * field in mailbox registers. The mailbox with highest value in priority field
* is transmitted first. Only when two mailboxes have the same value in * is transmitted first. Only when two mailboxes have the same value in
* priority field the highest numbered mailbox is transmitted first. * priority field the highest numbered mailbox is transmitted first.
...@@ -857,7 +857,7 @@ static int ti_hecc_probe(struct platform_device *pdev) ...@@ -857,7 +857,7 @@ static int ti_hecc_probe(struct platform_device *pdev)
struct net_device *ndev = (struct net_device *)0; struct net_device *ndev = (struct net_device *)0;
struct ti_hecc_priv *priv; struct ti_hecc_priv *priv;
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
struct resource *res, *irq; struct resource *irq;
struct regulator *reg_xceiver; struct regulator *reg_xceiver;
int err = -ENODEV; int err = -ENODEV;
...@@ -878,39 +878,22 @@ static int ti_hecc_probe(struct platform_device *pdev) ...@@ -878,39 +878,22 @@ static int ti_hecc_probe(struct platform_device *pdev)
priv = netdev_priv(ndev); priv = netdev_priv(ndev);
/* handle hecc memory */ /* handle hecc memory */
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hecc"); priv->base = devm_platform_ioremap_resource_byname(pdev, "hecc");
if (!res) {
dev_err(&pdev->dev, "can't get IORESOURCE_MEM hecc\n");
return -EINVAL;
}
priv->base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(priv->base)) { if (IS_ERR(priv->base)) {
dev_err(&pdev->dev, "hecc ioremap failed\n"); dev_err(&pdev->dev, "hecc ioremap failed\n");
return PTR_ERR(priv->base); return PTR_ERR(priv->base);
} }
/* handle hecc-ram memory */ /* handle hecc-ram memory */
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hecc-ram"); priv->hecc_ram = devm_platform_ioremap_resource_byname(pdev,
if (!res) { "hecc-ram");
dev_err(&pdev->dev, "can't get IORESOURCE_MEM hecc-ram\n");
return -EINVAL;
}
priv->hecc_ram = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(priv->hecc_ram)) { if (IS_ERR(priv->hecc_ram)) {
dev_err(&pdev->dev, "hecc-ram ioremap failed\n"); dev_err(&pdev->dev, "hecc-ram ioremap failed\n");
return PTR_ERR(priv->hecc_ram); return PTR_ERR(priv->hecc_ram);
} }
/* handle mbx memory */ /* handle mbx memory */
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mbx"); priv->mbx = devm_platform_ioremap_resource_byname(pdev, "mbx");
if (!res) {
dev_err(&pdev->dev, "can't get IORESOURCE_MEM mbx\n");
return -EINVAL;
}
priv->mbx = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(priv->mbx)) { if (IS_ERR(priv->mbx)) {
dev_err(&pdev->dev, "mbx ioremap failed\n"); dev_err(&pdev->dev, "mbx ioremap failed\n");
return PTR_ERR(priv->mbx); return PTR_ERR(priv->mbx);
......
...@@ -90,7 +90,7 @@ config CAN_PEAK_USB ...@@ -90,7 +90,7 @@ config CAN_PEAK_USB
tristate "PEAK PCAN-USB/USB Pro interfaces for CAN 2.0b/CAN-FD" tristate "PEAK PCAN-USB/USB Pro interfaces for CAN 2.0b/CAN-FD"
help help
This driver supports the PEAK-System Technik USB adapters that enable This driver supports the PEAK-System Technik USB adapters that enable
access to the CAN bus, with repect to the CAN 2.0b and/or CAN-FD access to the CAN bus, with respect to the CAN 2.0b and/or CAN-FD
standards, that is: standards, that is:
PCAN-USB single CAN 2.0b channel USB adapter PCAN-USB single CAN 2.0b channel USB adapter
......
...@@ -828,7 +828,7 @@ static struct gs_can *gs_make_candev(unsigned int channel, ...@@ -828,7 +828,7 @@ static struct gs_can *gs_make_candev(unsigned int channel,
netdev->flags |= IFF_ECHO; /* we support full roundtrip echo */ netdev->flags |= IFF_ECHO; /* we support full roundtrip echo */
/* dev settup */ /* dev setup */
strcpy(dev->bt_const.name, "gs_usb"); strcpy(dev->bt_const.name, "gs_usb");
dev->bt_const.tseg1_min = bt_const->tseg1_min; dev->bt_const.tseg1_min = bt_const->tseg1_min;
dev->bt_const.tseg1_max = bt_const->tseg1_max; dev->bt_const.tseg1_max = bt_const->tseg1_max;
...@@ -852,7 +852,7 @@ static struct gs_can *gs_make_candev(unsigned int channel, ...@@ -852,7 +852,7 @@ static struct gs_can *gs_make_candev(unsigned int channel,
dev->tx_context[rc].echo_id = GS_MAX_TX_URBS; dev->tx_context[rc].echo_id = GS_MAX_TX_URBS;
} }
/* can settup */ /* can setup */
dev->can.state = CAN_STATE_STOPPED; dev->can.state = CAN_STATE_STOPPED;
dev->can.clock.freq = bt_const->fclk_can; dev->can.clock.freq = bt_const->fclk_can;
dev->can.bittiming_const = &dev->bt_const; dev->can.bittiming_const = &dev->bt_const;
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#define MCBA_CTX_FREE MCBA_MAX_TX_URBS #define MCBA_CTX_FREE MCBA_MAX_TX_URBS
/* RX buffer must be bigger than msg size since at the /* RX buffer must be bigger than msg size since at the
* beggining USB messages are stacked. * beginning USB messages are stacked.
*/ */
#define MCBA_USB_RX_BUFF_SIZE 64 #define MCBA_USB_RX_BUFF_SIZE 64
#define MCBA_USB_TX_BUFF_SIZE (sizeof(struct mcba_usb_msg)) #define MCBA_USB_TX_BUFF_SIZE (sizeof(struct mcba_usb_msg))
...@@ -793,7 +793,7 @@ static int mcba_usb_probe(struct usb_interface *intf, ...@@ -793,7 +793,7 @@ static int mcba_usb_probe(struct usb_interface *intf,
{ {
struct net_device *netdev; struct net_device *netdev;
struct mcba_priv *priv; struct mcba_priv *priv;
int err = -ENOMEM; int err;
struct usb_device *usbdev = interface_to_usbdev(intf); struct usb_device *usbdev = interface_to_usbdev(intf);
netdev = alloc_candev(sizeof(struct mcba_priv), MCBA_MAX_TX_URBS); netdev = alloc_candev(sizeof(struct mcba_priv), MCBA_MAX_TX_URBS);
......
This diff is collapsed.
...@@ -35,7 +35,7 @@ MODULE_SUPPORTED_DEVICE("PEAK-System PCAN-USB Pro FD adapter"); ...@@ -35,7 +35,7 @@ MODULE_SUPPORTED_DEVICE("PEAK-System PCAN-USB Pro FD adapter");
#define PCAN_UFD_RX_BUFFER_SIZE 2048 #define PCAN_UFD_RX_BUFFER_SIZE 2048
#define PCAN_UFD_TX_BUFFER_SIZE 512 #define PCAN_UFD_TX_BUFFER_SIZE 512
/* read some versions info from the hw devcie */ /* read some versions info from the hw device */
struct __packed pcan_ufd_fw_info { struct __packed pcan_ufd_fw_info {
__le16 size_of; /* sizeof this */ __le16 size_of; /* sizeof this */
__le16 type; /* type of this structure */ __le16 type; /* type of this structure */
...@@ -796,7 +796,7 @@ static int pcan_usb_fd_start(struct peak_usb_device *dev) ...@@ -796,7 +796,7 @@ static int pcan_usb_fd_start(struct peak_usb_device *dev)
return err; return err;
} }
/* socket callback used to copy berr counters values receieved through USB */ /* socket callback used to copy berr counters values received through USB */
static int pcan_usb_fd_get_berr_counter(const struct net_device *netdev, static int pcan_usb_fd_get_berr_counter(const struct net_device *netdev,
struct can_berr_counter *bec) struct can_berr_counter *bec)
{ {
......
...@@ -186,7 +186,7 @@ static int pcan_msg_add_rec(struct pcan_usb_pro_msg *pm, int id, ...) ...@@ -186,7 +186,7 @@ static int pcan_msg_add_rec(struct pcan_usb_pro_msg *pm, int id, ...)
len = pc - pm->rec_ptr; len = pc - pm->rec_ptr;
if (len > 0) { if (len > 0) {
*pm->u.rec_cnt = cpu_to_le32(le32_to_cpu(*pm->u.rec_cnt) + 1); le32_add_cpu(pm->u.rec_cnt, 1);
*pm->rec_ptr = id; *pm->rec_ptr = id;
pm->rec_ptr = pc; pm->rec_ptr = pc;
...@@ -973,7 +973,7 @@ int pcan_usb_pro_probe(struct usb_interface *intf) ...@@ -973,7 +973,7 @@ int pcan_usb_pro_probe(struct usb_interface *intf)
struct usb_endpoint_descriptor *ep = &if_desc->endpoint[i].desc; struct usb_endpoint_descriptor *ep = &if_desc->endpoint[i].desc;
/* /*
* below is the list of valid ep addreses. Any other ep address * below is the list of valid ep addresses. Any other ep address
* is considered as not-CAN interface address => no dev created * is considered as not-CAN interface address => no dev created
*/ */
switch (ep->bEndpointAddress) { switch (ep->bEndpointAddress) {
......
...@@ -1445,7 +1445,7 @@ static int ucan_probe(struct usb_interface *intf, ...@@ -1445,7 +1445,7 @@ static int ucan_probe(struct usb_interface *intf,
/* request the device information and store it in ctl_msg_buffer /* request the device information and store it in ctl_msg_buffer
* *
* note: ucan_ctrl_command_* wrappers connot be used yet * note: ucan_ctrl_command_* wrappers cannot be used yet
* because `up` is initialised in Stage 3 * because `up` is initialised in Stage 3
*/ */
ret = usb_control_msg(udev, ret = usb_control_msg(udev,
...@@ -1494,7 +1494,7 @@ static int ucan_probe(struct usb_interface *intf, ...@@ -1494,7 +1494,7 @@ static int ucan_probe(struct usb_interface *intf,
up = netdev_priv(netdev); up = netdev_priv(netdev);
/* initialze data */ /* initialize data */
up->udev = udev; up->udev = udev;
up->intf = intf; up->intf = intf;
up->netdev = netdev; up->netdev = netdev;
......
...@@ -88,7 +88,7 @@ enum usb_8dev_cmd { ...@@ -88,7 +88,7 @@ enum usb_8dev_cmd {
/* status */ /* status */
#define USB_8DEV_STATUSMSG_OK 0x00 /* Normal condition. */ #define USB_8DEV_STATUSMSG_OK 0x00 /* Normal condition. */
#define USB_8DEV_STATUSMSG_OVERRUN 0x01 /* Overrun occured when sending */ #define USB_8DEV_STATUSMSG_OVERRUN 0x01 /* Overrun occurred when sending */
#define USB_8DEV_STATUSMSG_BUSLIGHT 0x02 /* Error counter has reached 96 */ #define USB_8DEV_STATUSMSG_BUSLIGHT 0x02 /* Error counter has reached 96 */
#define USB_8DEV_STATUSMSG_BUSHEAVY 0x03 /* Error count. has reached 128 */ #define USB_8DEV_STATUSMSG_BUSHEAVY 0x03 /* Error count. has reached 128 */
#define USB_8DEV_STATUSMSG_BUSOFF 0x04 /* Device is in BUSOFF */ #define USB_8DEV_STATUSMSG_BUSOFF 0x04 /* Device is in BUSOFF */
...@@ -165,7 +165,7 @@ struct __packed usb_8dev_rx_msg { ...@@ -165,7 +165,7 @@ struct __packed usb_8dev_rx_msg {
/* command frame */ /* command frame */
struct __packed usb_8dev_cmd_msg { struct __packed usb_8dev_cmd_msg {
u8 begin; u8 begin;
u8 channel; /* unkown - always 0 */ u8 channel; /* unknown - always 0 */
u8 command; /* command to execute */ u8 command; /* command to execute */
u8 opt1; /* optional parameter / return value */ u8 opt1; /* optional parameter / return value */
u8 opt2; /* optional parameter 2 */ u8 opt2; /* optional parameter 2 */
......
...@@ -1308,7 +1308,7 @@ static void xcan_tx_interrupt(struct net_device *ndev, u32 isr) ...@@ -1308,7 +1308,7 @@ static void xcan_tx_interrupt(struct net_device *ndev, u32 isr)
/** /**
* xcan_interrupt - CAN Isr * xcan_interrupt - CAN Isr
* @irq: irq number * @irq: irq number
* @dev_id: device id poniter * @dev_id: device id pointer
* *
* This is the xilinx CAN Isr. It checks for the type of interrupt * This is the xilinx CAN Isr. It checks for the type of interrupt
* and invokes the corresponding ISR. * and invokes the corresponding ISR.
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* /*
* linux/can/core.h * linux/can/core.h
* *
* Protoypes and definitions for CAN protocol modules using the PF_CAN core * Prototypes and definitions for CAN protocol modules using the PF_CAN core
* *
* Authors: Oliver Hartkopp <oliver.hartkopp@volkswagen.de> * Authors: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
* Urs Thuermann <urs.thuermann@volkswagen.de> * Urs Thuermann <urs.thuermann@volkswagen.de>
......
...@@ -108,7 +108,7 @@ static inline bool can_skb_headroom_valid(struct net_device *dev, ...@@ -108,7 +108,7 @@ static inline bool can_skb_headroom_valid(struct net_device *dev,
skb->ip_summed = CHECKSUM_UNNECESSARY; skb->ip_summed = CHECKSUM_UNNECESSARY;
/* preform proper loopback on capable devices */ /* perform proper loopback on capable devices */
if (dev->flags & IFF_ECHO) if (dev->flags & IFF_ECHO)
skb->pkt_type = PACKET_LOOPBACK; skb->pkt_type = PACKET_LOOPBACK;
else else
...@@ -201,8 +201,8 @@ void can_bus_off(struct net_device *dev); ...@@ -201,8 +201,8 @@ void can_bus_off(struct net_device *dev);
void can_change_state(struct net_device *dev, struct can_frame *cf, void can_change_state(struct net_device *dev, struct can_frame *cf,
enum can_state tx_state, enum can_state rx_state); enum can_state tx_state, enum can_state rx_state);
void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, int can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
unsigned int idx); unsigned int idx);
struct sk_buff *__can_get_echo_skb(struct net_device *dev, unsigned int idx, struct sk_buff *__can_get_echo_skb(struct net_device *dev, unsigned int idx,
u8 *len_ptr); u8 *len_ptr);
unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx); unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx);
......
...@@ -35,6 +35,9 @@ int can_rx_offload_add_timestamp(struct net_device *dev, ...@@ -35,6 +35,9 @@ int can_rx_offload_add_timestamp(struct net_device *dev,
int can_rx_offload_add_fifo(struct net_device *dev, int can_rx_offload_add_fifo(struct net_device *dev,
struct can_rx_offload *offload, struct can_rx_offload *offload,
unsigned int weight); unsigned int weight);
int can_rx_offload_add_manual(struct net_device *dev,
struct can_rx_offload *offload,
unsigned int weight);
int can_rx_offload_irq_offload_timestamp(struct can_rx_offload *offload, int can_rx_offload_irq_offload_timestamp(struct can_rx_offload *offload,
u64 reg); u64 reg);
int can_rx_offload_irq_offload_fifo(struct can_rx_offload *offload); int can_rx_offload_irq_offload_fifo(struct can_rx_offload *offload);
......
...@@ -358,7 +358,7 @@ static unsigned int effhash(canid_t can_id) ...@@ -358,7 +358,7 @@ static unsigned int effhash(canid_t can_id)
* *
* Return: * Return:
* Pointer to optimal filterlist for the given can_id/mask pair. * Pointer to optimal filterlist for the given can_id/mask pair.
* Constistency checked mask. * Consistency checked mask.
* Reduced can_id to have a preprocessed filter compare value. * Reduced can_id to have a preprocessed filter compare value.
*/ */
static struct hlist_head *can_rcv_list_find(canid_t *can_id, canid_t *mask, static struct hlist_head *can_rcv_list_find(canid_t *can_id, canid_t *mask,
...@@ -411,7 +411,7 @@ static struct hlist_head *can_rcv_list_find(canid_t *can_id, canid_t *mask, ...@@ -411,7 +411,7 @@ static struct hlist_head *can_rcv_list_find(canid_t *can_id, canid_t *mask,
/** /**
* can_rx_register - subscribe CAN frames from a specific interface * can_rx_register - subscribe CAN frames from a specific interface
* @net: the applicable net namespace * @net: the applicable net namespace
* @dev: pointer to netdevice (NULL => subcribe from 'all' CAN devices list) * @dev: pointer to netdevice (NULL => subscribe from 'all' CAN devices list)
* @can_id: CAN identifier (see description) * @can_id: CAN identifier (see description)
* @mask: CAN mask (see description) * @mask: CAN mask (see description)
* @func: callback function on filter match * @func: callback function on filter match
......
// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) // SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
/* /*
* bcm.c - Broadcast Manager to filter/send (cyclic) CAN content * bcm.c - Broadcast Manager to filter/send (cyclic) CAN content
* *
......
// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) // SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
/* gw.c - CAN frame Gateway/Router/Bridge with netlink interface /* gw.c - CAN frame Gateway/Router/Bridge with netlink interface
* *
* Copyright (c) 2019 Volkswagen Group Electronic Research * Copyright (c) 2019 Volkswagen Group Electronic Research
......
// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) // SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
/* /*
* proc.c - procfs support for Protocol family CAN core module * proc.c - procfs support for Protocol family CAN core module
* *
......
This diff is collapsed.
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