summaryrefslogtreecommitdiff
path: root/drivers/net/can/flexcan.c
AgeCommit message (Collapse)Author
2019-11-04can: flexcan: increase error counters if skb enqueueing via ↵Marc Kleine-Budde
can_rx_offload_queue_sorted() fails The call to can_rx_offload_queue_sorted() may fail and return an error (in the current implementation due to resource shortage). The passed skb is consumed. This patch adds incrementing of the appropriate error counters to let the device statistics reflect that there's a problem. Reported-by: Martin Hundebøll <martin@geanix.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2019-11-04can: flexcan: disable completely the ECC mechanismJoakim Zhang
The ECC (memory error detection and correction) mechanism can be activated or not, controlled by the ECCDIS bit in CAN_MECR. When disabled, updates on indications and reporting registers are stopped. So if want to disable ECC completely, had better assert ECCDIS bit, not just mask the related interrupts. Fixes: cdce844865be ("can: flexcan: add vf610 support for FlexCAN") Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com> Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2019-08-06Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/netDavid S. Miller
Just minor overlapping changes in the conflicts here. Signed-off-by: David S. Miller <davem@davemloft.net>
2019-07-24can: flexcan: fix stop mode acknowledgmentJoakim Zhang
To enter stop mode, the CPU should manually assert a global Stop Mode request and check the acknowledgment asserted by FlexCAN. The CPU must only consider the FlexCAN in stop mode when both request and acknowledgment conditions are satisfied. Fixes: de3578c198c6 ("can: flexcan: add self wakeup support") Reported-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com> Cc: linux-stable <stable@vger.kernel.org> # >= v5.0 Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2019-07-24can: flexcan: fix an use-after-free in flexcan_setup_stop_mode()Wen Yang
The gpr_np variable is still being used in dev_dbg() after the of_node_put() call, which may result in use-after-free. Fixes: de3578c198c6 ("can: flexcan: add self wakeup support") Signed-off-by: Wen Yang <wen.yang99@zte.com.cn> Cc: linux-stable <stable@vger.kernel.org> # >= v5.0 Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2019-07-24can: flexcan: add support for DT property 'wakeup-source'Sean Nyekjaer
The flexcan controller can be forced as a wakeup source by stating that explicitly in the device's .dts file using the "wakeup-source" boolean property. Signed-off-by: Sean Nyekjaer <sean@geanix.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2019-07-24can: flexcan: add support for PE clock source selectDong Aisheng
Add support to select the clock source for CAN Protocol Engine (PE). It's SoC Implementation dependent. Refer to RM for detailed definition of each SoC. We select clock source 1 (peripheral clock) by default in driver now, this patch adds support to parse the clock source from the DT. Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com> Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2019-07-24can: flexcan: implement can Runtime PMAisheng Dong
Flexcan will be disabled during suspend if no wakeup function required and enabled after resume accordingly. During this period, we could explicitly disable clocks. Since PM is optional, the clock is enabled at probe to guarante the clock is running when PM is not enabled in the kernel. Implement Runtime PM which will: 1) Without CONFIG_PM, clock is running whether Flexcan up or down. 2) With CONFIG_PM, clock enabled while Flexcan up and disabled when Flexcan down. 3) Disable clock when do system suspend and enable clock while system resume. 4) Make Power Domain framework be able to shutdown the corresponding power domain of this device. Signed-off-by: Aisheng Dong <aisheng.dong@nxp.com> Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2019-06-07can: flexcan: Remove unneeded registration messageFabio Estevam
Currently the following message is observed when the flexcan driver is probed: flexcan 2090000.flexcan: device registered (reg_base=(ptrval), irq=23) The reason for printing 'ptrval' is explained at Documentation/core-api/printk-formats.rst: "Pointers printed without a specifier extension (i.e unadorned %p) are hashed to prevent leaking information about the kernel memory layout. This has the added benefit of providing a unique identifier. On 64-bit machines the first 32 bits are zeroed. The kernel will print ``(ptrval)`` until it gathers enough entropy." Instead of passing %pK, which can print the correct address, simply remove the entire message as it is not really that useful. Signed-off-by: Fabio Estevam <festevam@gmail.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2019-06-07can: flexcan: fix timeout when set small bitrateJoakim Zhang
Current we can meet timeout issue when setting a small bitrate like 10000 as follows on i.MX6UL EVK board (ipg clock = 66MHZ, per clock = 30MHZ): | root@imx6ul7d:~# ip link set can0 up type can bitrate 10000 A link change request failed with some changes committed already. Interface can0 may have been left with an inconsistent configuration, please check. | RTNETLINK answers: Connection timed out It is caused by calling of flexcan_chip_unfreeze() timeout. Originally the code is using usleep_range(10, 20) for unfreeze operation, but the patch (8badd65 can: flexcan: avoid calling usleep_range from interrupt context) changed it into udelay(10) which is only a half delay of before, there're also some other delay changes. After double to FLEXCAN_TIMEOUT_US to 100 can fix the issue. Meanwhile, Rasmus Villemoes reported that even with a timeout of 100, flexcan_probe() fails on the MPC8309, which requires a value of at least 140 to work reliably. 250 works for everyone. Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com> Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com> Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2019-01-22can: flexcan: fix NULL pointer exception during bringupUwe Kleine-König
Commit cbffaf7aa09e ("can: flexcan: Always use last mailbox for TX") introduced a loop letting i run up to (including) ARRAY_SIZE(regs->mb) and in the body accessed regs->mb[i] which is an out-of-bounds array access that then resulted in an access to an reserved register area. Later this was changed by commit 0517961ccdf1 ("can: flexcan: Add provision for variable payload size") to iterate a bit differently but still runs one iteration too much resulting to call flexcan_get_mb(priv, priv->mb_count) which results in a WARN_ON and then a NULL pointer exception. This only affects devices compatible with "fsl,p1010-flexcan", "fsl,imx53-flexcan", "fsl,imx35-flexcan", "fsl,imx25-flexcan", "fsl,imx28-flexcan", so newer i.MX SoCs are not affected. Fixes: cbffaf7aa09e ("can: flexcan: Always use last mailbox for TX") Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Cc: linux-stable <stable@vger.kernel.org> # >= 4.20 Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2019-01-22can: flexcan: fix 'passing zero to ERR_PTR()' warningYueHaibing
Fix a static code checker warning: drivers/net/can/flexcan.c:1435 flexcan_setup_stop_mode() warn: passing zero to 'PTR_ERR' Fixes: de3578c198c6 ("can: flexcan: add self wakeup support") Signed-off-by: YueHaibing <yuehaibing@huawei.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2018-11-28can: flexcan: split the Message Buffer RAM areaPankaj Bansal
The message buffer RAM area is not a contiguous 1KB area but 2 partitions of 512 bytes each. Till now, we used Message buffers with payload size 8 bytes, which translates to 32 MBs per partition and no spare space is left in any partition. However, in upcoming SOC LX2160A the message buffers can have payload size 64 bytes. This results in less than 32 MBs per partition and some empty area is left at the end of each partition.This empty area should not be accessed. Therefore, split the Message Buffer RAM area into two partitions. Signed-off-by: Pankaj Bansal <pankaj.bansal@nxp.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2018-11-28can: flexcan: Add provision for variable payload sizePankaj Bansal
Till now the flexcan module supported 8 byte payload size as per CAN 2.0 specifications. But now upcoming flexcan module in NXP LX2160A SOC supports CAN FD protocol too. The Message buffers need to be configured to have payload size 64 bytes. Therefore, added provision in the driver for payload size to be 64 bytes. Signed-off-by: Pankaj Bansal <pankaj.bansal@nxp.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2018-11-28can: flexcan: move rx_offload_add() from flexcan_probe() to flexcan_open()Pankaj Bansal
rx offload depends on number of message buffers, which in turn depends on messgae buffer size. with the upcoming LX2160A SOC the message buffer size can be configured to 72 bytes if it were to be used in CAN FD mode. The current mode in which the flexcan is being operated is known at the time of flexcan_open() but not at the time of flexcan_probe(). Therefore, move the rx_offload_add() from flexcan_probe() to flexcan_open(). correspondingly, move rx_offload_delete() from flexcan_remove() to flexcan_close(). Signed-off-by: Pankaj Bansal <pankaj.bansal@nxp.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2018-11-28can: flexcan: flexcan_chip_start(): enable loopback mode in flexcanPankaj Bansal
Self reception disable bit needs to be cleared for loopback mode to work in flexcan. Signed-off-by: Pankaj Bansal <pankaj.bansal@nxp.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2018-11-28can: flexcan: add self wakeup supportAisheng Dong
If wakeup is enabled, enter stop mode, else enter disabled mode. Self wake can only work on stop mode. Starting from IMX6, the flexcan stop mode control bits is SoC specific, move it out of IP driver and parse it from devicetree. Signed-off-by: Aisheng Dong <aisheng.dong@nxp.com> Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com> Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2018-11-28can: flexcan: flexcan_chip_start(): adjust comment to match the codeMarc Kleine-Budde
With the conversion of the flexcan driver to support both timestamp and FIFO mode the setup of the MCR register ("enable fifo") has been moved. This patch moves the comment too, in order to match the code again. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2018-11-28can: flexcan: FLEXCAN_IFLAG_MB: add () around macro argumentMarc Kleine-Budde
This patch fixes the following checkpatch warning: | Macro argument 'x' may be better as '(x)' to avoid precedence issues Fixes: cbffaf7aa09e ("can: flexcan: Always use last mailbox for TX") Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2018-11-28can: flexcan: flexcan_irq(): fix indentionMarc Kleine-Budde
The patch fixes the indention by replacing space by tabs, as noted by checkpatch: | ERROR: code indent should use tabs where possible | #980: FILE: drivers/net/can/flexcan.c:980: Fixes: da49a8075c00 ("can: flexcan: implement error passive state quirk") Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2018-11-28can: flexcan: flexcan_start_xmit(): fix indentionMarc Kleine-Budde
This patch fixes the indentio nin flexcan_start_xmit() by alligning the code to the opening parenthesis. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2018-11-09can: flexcan: use can_rx_offload_queue_sorted() for flexcan_irq_bus_*()Oleksij Rempel
Currently, in case of bus error, driver will generate error message and put in the tail of the message queue. To avoid confusions, this change should place the bus related messages in proper order. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2018-11-09can: rx-offload: rename can_rx_offload_irq_queue_err_skb() to ↵Oleksij Rempel
can_rx_offload_queue_tail() This function has nothing todo with error. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2018-11-09can: flexcan: handle tx-complete CAN frames via rx-offload infrastructureOleksij Rempel
Current flexcan driver will put TX-ECHO in regular unsorted way, in this case TX-ECHO can come after the response to the same TXed message. In some cases, for example for J1939 stack, things will break. This patch is using new rx-offload API to put the messages just in the right place. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2018-11-09can: flexcan: remove not needed struct flexcan_priv::tx_mb and struct ↵Marc Kleine-Budde
flexcan_priv::tx_mb_idx The previous patch changes the TX path to always use the last mailbox regardless of the used offload scheme (rx-fifo or timestamp based). This means members "tx_mb" and "tx_mb_idx" of the struct flexcan_priv don't depend on the offload scheme, so replace them by compile time constants. Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2018-11-09can: flexcan: Always use last mailbox for TXAlexander Stein
Essentially this patch moves the TX mailbox to position 63, regardless of timestamp based offloading or RX FIFO. So mainly the iflag register usage regarding TX has changed. The rest is consolidating RX FIFO and timestamp offloading as they now use both the same TX mailbox. The reason is a very annoying behavior regarding sending RTR frames when _not_ using RX FIFO: If a TX mailbox sent a RTR frame it becomes a RX mailbox. For that reason flexcan_irq disables the TX mailbox again. But if during the time the RTR was sent and the TX mailbox is disabled a new CAN frames is received, it is lost without notice. The reason is that so-called "Move-in" process starts from the lowest mailbox which happen to be a TX mailbox set to EMPTY. Steps to reproduce (I used an imx7d): 1. generate regular bursts of messages 2. send a RTR from flexcan with higher priority than burst messages every 1ms, e.g. cangen -I 0x100 -L 0 -g 1 -R can0 3. notice a lost message without notification after some seconds When running an iperf in parallel this problem is occurring even more frequently. Using filters is not possible as at least one single CAN-ID is allowed. Handling the TX MB during RX is also not possible as there is no race-free disable of RX MB. There is still a slight window when the described problem can occur. But for that all RX MB must be in use which is essentially next to an overrun. Still there will be no indication if it ever occurs. Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com> Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2018-11-09can: flexcan: Unlock the MB unconditionallyPankaj Bansal
Unlock the MB irrespective of reception method being FIFO or timestamp based. It is optional but recommended to unlock Mailbox as soon as possible and make it available for reception. Reported-by: Alexander Stein <alexander.stein@systec-electronic.com> Signed-off-by: Pankaj Bansal <pankaj.bansal@nxp.com> Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2018-07-27can: flexcan: Switch to SPDX identifierFabio Estevam
Adopt the SPDX license identifier headers to ease license compliance management. Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2018-07-27can: flexcan: fix flexcan_start_xmit()'s return typeMarc Kleine-Budde
The method ndo_start_xmit() is defined as returning an 'netdev_tx_t', which is a typedef for an enum type, but the implementation in this driver returns an 'int'. Fix this by returning 'netdev_tx_t' in this driver too. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2018-05-08can: flexcan: fix endianess detectionUwe Kleine-König
In commit 88462d2a7830 ("can: flexcan: Remodel FlexCAN register r/w APIs for big endian FlexCAN controllers.") the following logic was implemented: if the dt property "big-endian" is given or the device is compatible to "fsl,p1010-flexcan": use big-endian mode; else use little-endian mode; This relies on commit d50f4630c2e1 ("arm: dts: Remove p1010-flexcan compatible from imx series dts") which was applied a few commits later. Without this commit (or an old device tree used for booting a new kernel) the flexcan devices on i.MX25, i.MX28, i.MX35 and i.MX53 match the 'the device is compatible to "fsl,p1010-flexcan"' test and so are switched erroneously to big endian mode. Instead of the check above put a quirk in devtype data and rely on of_match_device yielding the most compatible match Fixes: 88462d2a7830 ("can: flexcan: Remodel FlexCAN register r/w APIs for big endian FlexCAN controllers.") Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Tested-by: Gavin Schenk <g.schenk@eckelmann.de> Cc: linux-stable <stable@vger.kernel.org> # >= v4.16 Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2018-01-09Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/netDavid S. Miller
2018-01-04can: flex_can: Correct the checking for frame length in flexcan_start_xmit()Luu An Phu
The flexcan_start_xmit() function compares the frame length with data register length to write frame content into data[0] and data[1] register. Data register length is 4 bytes and frame maximum length is 8 bytes. Fix the check that compares frame length with 3. Because the register length is 4. Signed-off-by: Luu An Phu <phu.luuan@nxp.com> Reviewed-by: Oliver Hartkopp <socketcan@hartkopp.net> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2017-12-05Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/netDavid S. Miller
Small overlapping change conflict ('net' changed a line, 'net-next' added a line right afterwards) in flexcan.c Signed-off-by: David S. Miller <davem@davemloft.net>
2017-12-01can: flexcan: fix VF610 state transition issueMarc Kleine-Budde
Enable FLEXCAN_QUIRK_BROKEN_PERR_STATE for VF610 to report correct state transitions. Tested-by: Mirza Krak <mirza.krak@gmail.com> Cc: linux-stable <stable@vger.kernel.org> # >= v4.11 Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2017-12-01can: flexcan: Update IRQ Err Passive informationMarc Kleine-Budde
The flexcan IP cores used on MX25 and MX35 do not generate Error Passive IRQs. Update the IP core overview table in the driver accordingly. Suggested-by: ZHU Yi (ST-FIR/ENG1-Zhu) <Yi.Zhu5@cn.bosch.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2017-12-01can: flexcan: adding platform specific details for LS1021APankaj Bansal
This patch adds platform specific details for NXP SOC LS1021A to the flexcan driver code. Signed-off-by: Pankaj Bansal <pankaj.bansal@nxp.com> Signed-off-by: Bhupesh Sharma <bhupesh.sharma@freescale.com> Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com> Reviewed-by: Poonam Aggrwal <poonam.aggrwal@nxp.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2017-12-01can: flexcan: Remodel FlexCAN register r/w APIs for big endian FlexCAN ↵Pankaj Bansal
controllers. The FlexCAN driver assumed that FlexCAN controller is big endian for powerpc architecture and little endian for other architectures. But this may not be the case. FlexCAN controller can be little or big endian on any architecture. For e.g. NXP LS1021A ARM based SOC has big endian FlexCAN controller. Therefore, the driver has been modified to add a provision for both types of controllers using an additional device tree property. On a "fsl,p1010-flexcan" device BE is default, on all other devices LE is. Big Endian controllers should have "big-endian" set in the device tree. check "Documentation/devicetree/bindings/net/can/fsl-flexcan.txt" for usage. This is the standard practice followed in linux. for more info check: Documentation/devicetree/bindings/common-properties.txt Signed-off-by: Pankaj Bansal <pankaj.bansal@nxp.com> Signed-off-by: Bhupesh Sharma <bhupesh.sharma@freescale.com> Signed-off-by: Sakar Arora <Sakar.Arora@freescale.com> Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com> Reviewed-by: Poonam Aggrwal <poonam.aggrwal@nxp.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2017-10-19can: flexcan: fix p1010 state transition issueZHU Yi (ST-FIR/ENG1-Zhu)
Enable FLEXCAN_QUIRK_BROKEN_WERR_STATE and FLEXCAN_QUIRK_BROKEN_PERR_STATE for p1010 to report correct state transitions. Signed-off-by: Zhu Yi <yi.zhu5@cn.bosch.com> Signed-off-by: Mark Jonas <mark.jonas@de.bosch.com> Acked-by: Wolfgang Grandegger <wg@grandegger.com> Cc: linux-stable <stable@vger.kernel.org> # >= v4.11 Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2017-10-19can: flexcan: fix i.MX28 state transition issueZHU Yi (ST-FIR/ENG1-Zhu)
Enable FLEXCAN_QUIRK_BROKEN_PERR_STATE for i.MX28 to report correct state transitions, especially to error passive. Signed-off-by: Wolfgang Grandegger <wg@grandegger.com> Signed-off-by: Zhu Yi <yi.zhu5@cn.bosch.com> Signed-off-by: Mark Jonas <mark.jonas@de.bosch.com> Cc: linux-stable <stable@vger.kernel.org> # >= v4.11 Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2017-10-19can: flexcan: fix i.MX6 state transition issueZHU Yi (ST-FIR/ENG1-Zhu)
Enable FLEXCAN_QUIRK_BROKEN_PERR_STATE for i.MX6 to report correct state transitions. Signed-off-by: Zhu Yi <yi.zhu5@cn.bosch.com> Signed-off-by: Mark Jonas <mark.jonas@de.bosch.com> Acked-by: Wolfgang Grandegger <wg@grandegger.com> Cc: linux-stable <stable@vger.kernel.org> # >= v4.11 Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2017-10-19can: flexcan: implement error passive state quirkZHU Yi (ST-FIR/ENG1-Zhu)
Add FLEXCAN_QUIRK_BROKEN_PERR_STATE for better description of the missing error passive interrupt quirk. Error interrupt flooding may happen if the broken error state quirk fix is enabled. For example, in case there is singled out node on the bus and the node sends a frame, then error interrupt flooding happens and will not stop because the node cannot go to bus off. The flooding will stop after another node connected to the bus again. If high bitrate configured on the low end system, then the flooding may causes performance issue, hence, this patch mitigates this by: 1. disable error interrupt upon error passive state transition 2. re-enable error interrupt upon error warning state transition 3. disable/enable error interrupt upon error active state transition depends on FLEXCAN_QUIRK_BROKEN_WERR_STATE In this way, the driver is still able to report correct state transitions without additional latency. When there are bus problems, flooding of error interrupts is limited to the number of frames required to change state from error warning to error passive if the core has [TR]WRN_INT connected (FLEXCAN_QUIRK_BROKEN_WERR_STATE is not enabled), otherwise, the flooding is limited to the number of frames required to change state from error active to error passive. Signed-off-by: Zhu Yi <yi.zhu5@cn.bosch.com> Signed-off-by: Mark Jonas <mark.jonas@de.bosch.com> Acked-by: Wolfgang Grandegger <wg@grandegger.com> Cc: linux-stable <stable@vger.kernel.org> # >= v4.11 Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2017-10-19can: flexcan: rename legacy error state quirkZHU Yi (ST-FIR/ENG1-Zhu)
Rename FLEXCAN_QUIRK_BROKEN_ERR_STATE to FLEXCAN_QUIRK_BROKEN_WERR_STATE for better description of the missing [TR]WRN_INT quirk. Signed-off-by: Zhu Yi <yi.zhu5@cn.bosch.com> Signed-off-by: Mark Jonas <mark.jonas@de.bosch.com> Acked-by: Wolfgang Grandegger <wg@grandegger.com> Cc: linux-stable <stable@vger.kernel.org> # >= v4.11 Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2017-10-19can: flexcan: fix state transition regressionZHU Yi (ST-FIR/ENG1-Zhu)
Update state upon any interrupt to report correct state transitions in case the flexcan core enabled the broken error state quirk fix. Signed-off-by: Zhu Yi <yi.zhu5@cn.bosch.com> Signed-off-by: Mark Jonas <mark.jonas@de.bosch.com> Acked-by: Wolfgang Grandegger <wg@grandegger.com> Cc: linux-stable <stable@vger.kernel.org> # >= v4.11 Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2017-03-03can: flexcan: fix typo in commentMarc Kleine-Budde
This patch fixes the typo "Disble" -> "Disable". Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2017-02-06can: flexcan: switch imx6 and vf610 to timestamp based offloadingMarc Kleine-Budde
This patch switches the imx6 and vf610 based SoCs from the hardware FIFO to the timestamp based rx offloading. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2017-02-06can: flexcan: add support for timestamp based rx-offloadMarc Kleine-Budde
The flexcan IP core has 64 mailboxes. For now they are configured for RX as a hardware FIFO. This FIFO has a fixed depth of 6 CAN frames. In some high load scenarios it turns out thas this buffer is too small. In order to have a buffer larger than the 6 frames FIFO, this patch adds support for timestamp based offloading via the generic rx-offload infrastructure. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2017-02-06can: flexcan: add quirk FLEXCAN_QUIRK_ENABLE_EACEN_RRSMarc Kleine-Budde
In order to receive RTR frames in the non HW FIFO mode the RSS and EACEN bits of the reg_ctrl2 have to be activated. As this has no side effect in the FIFO mode, we do this unconditionally on cores with the reg_ctrl2. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2017-02-06can: flexcan: activate individual RX masking and initialize reg_rximrMarc Kleine-Budde
Modern flexcan IP cores support two RX modes. One is using the 6 fames deep hardware FIFO, the other is using up to 64 mailboxes (in non FIFO mode). For now only the HW FIFO mode is activated. In order to make use of the RX mailboxes the individual RX masking feature has to be activated, otherwise matching mailboxes are overwritten during the reception process. This however switches on the individual RX masking, which uses reg_rximr registers for masking. This patch activates the individual RX masking feature unconditionally and initializes the mask registers (reg_rximr) with 0x0 == "don't care", which switches off any filtering. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2017-02-06can: flexcan: make use of rx-offload's irq_offload_fifoMarc Kleine-Budde
This patch converts the flexcan driver to make use of the rx-offload can_rx_offload_irq_offload_fifo() helper function. The idea is to read the CAN frames already in the interrupt context, as the depth of the flexcan HW FIFO is too shallow, resulting in too many missed frames. During a normal NAPI poll the frames are the pushed into the upper layers. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2017-02-06can: flexcan: make TX mailbox selectable during runtimeMarc Kleine-Budde
This patch makes the TX mailbox selectable duing runtime. This is a preparation patch to use of the hardware FIFO selectable via runtime. As the TX mailbox number is different in HW FIFO and normal mode. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>