aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/can/flexcan.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2018-07-27can: flexcan: Switch to SPDX identifierFabio Estevam1-21/+10
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-Budde1-1/+1
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önig1-12/+14
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. Miller1-1/+1
2018-01-04can: flex_can: Correct the checking for frame length in flexcan_start_xmit()Luu An Phu1-1/+1
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. Miller1-4/+5
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-Budde1-2/+3
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-Budde1-2/+2
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 Bansal1-0/+8
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 controllers.Pankaj Bansal1-102/+131
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)1-1/+2
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)1-1/+3
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)1-1/+1
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)1-9/+66
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)1-4/+4
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)1-2/+3
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-Budde1-1/+1
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-Budde1-2/+3
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-Budde1-29/+129
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-Budde1-3/+11
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-Budde1-1/+7
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-Budde1-112/+52
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-Budde1-18/+24
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>
2017-02-06can: flexcan: calculate default value for imask1 during runtimeMarc Kleine-Budde1-6/+8
This patch converts the define FLEXCAN_IFLAG_DEFAULT into the runtime calculated value priv->reg_imask1_default. This is a preparation patch to make the TX mailbox selectable during runtime, too. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2017-02-06can: flexcan: flexcan_irq(): don't unconditionally return IRQ_HANDLEDMarc Kleine-Budde1-5/+11
This patch changes the flexcan_irq() function to only return IRQ_HANDLED, if the interrupt really has been handled, otherwise IRQ_NONE is returned. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2017-02-06can: flexcan: flexcan_poll_bus_err(): fold in do_bus_err()Marc Kleine-Budde1-14/+7
This patch folds in the do_bus_err() function into flexcan_poll_bus_err(). Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2017-02-06can: flexcan: flexcan_poll_state(): no need to initialize new_state, rx_state, tx_stateMarc Kleine-Budde1-1/+1
This patch removed the not needed initialisation from the new_state, rx_state, tx_state variabled. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2017-02-06can: flexcan: do_bus_err(): convert rx_,tx_errors into boolMarc Kleine-Budde1-7/+7
This patch converts the rx_errors and tx_errors from int into bool values, to reflect their actual meaning. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2017-02-06can: flexcan: make declaration of devtype_data constMarc Kleine-Budde1-4/+4
This patch changes the declaration of the devtype data to const. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2017-02-06can: flexcan: remove write-only member pdata of struct flexcan_privMarc Kleine-Budde1-2/+0
This patch removes the write only member pdata from the struct flexcan_priv. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2017-02-06can: flexcan: add missing register definitionsMarc Kleine-Budde1-3/+10
This patch adds some missing register definitions, which are needed in an upcoming patch. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2017-01-30drivers: net: generalize napi_complete_done()Eric Dumazet1-1/+1
napi_complete_done() allows to opt-in for gro_flush_timeout, added back in linux-3.19, commit 3b47d30396ba ("net: gro: add a per device gro flush timer") This allows for more efficient GRO aggregation without sacrifying latencies. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-09-19can: flexcan: fix resume functionFabio Estevam1-5/+8
On a imx6ul-pico board the following error is seen during system suspend: dpm_run_callback(): platform_pm_resume+0x0/0x54 returns -110 PM: Device 2090000.flexcan failed to resume: error -110 The reason for this suspend error is because when the CAN interface is not active the clocks are disabled and then flexcan_chip_enable() will always fail due to a timeout error. In order to fix this issue, only call flexcan_chip_enable/disable() when the CAN interface is active. Based on a patch from Dong Aisheng in the NXP kernel. Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com> Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2015-11-23can: fix assignment of error location in CAN error messagesOliver Hartkopp1-2/+2
As Dan Carpenter reported in http://marc.info/?l=linux-can&m=144793696016187 the assignment of the error location in CAN error messages had some bit wise overlaps. Indeed the value to be assigned in data[3] is no bitfield but defines a single value which points to a location inside the CAN frame on the wire. This patch fixes the assignments for the error locations in error messages. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2015-09-21can: flexcan: enable interrupts atomically at the end of flexcan_chip_start()Marc Kleine-Budde1-1/+6
This patch defers the writing of the interrupts bits of the CTRL register order to enables all interrupts atomically at the the of the flexcan_chip_start() function. Suggested-by: Torsten Lang <torsten.lang@uweschneider.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2015-09-21can: flexcan: give member of flexcan_priv holding mailboxes a sensible nameMarc Kleine-Budde1-13/+13
This patch gives the member of flexcan_priv holding mailboxes a sensible name, by renaming from "cantxfg" to "mb": struct flexcan_priv::cantxfg -> struct flexcan_priv::mb Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2015-09-21can: flexcan: use pointer to struct regs instead of void pointer for mmio address spaceMarc Kleine-Budde1-21/+21
This patch renames the pointer to the mmio address space from "base" to "regs" and changes the type from "void __iomem *" to "struct flexcan_regs __iomem *". Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2015-09-21can: flexcan: rename feature into quirksMarc Kleine-Budde1-10/+10
This patch renames the "features" member of struct flexcan_devtype_data to "quirks". The corresponding defines are renamed too, to reflect what they actually do. FLEXCAN_HAS_V10_FEATURES -> FLEXCAN_QUIRK_DISABLE_RXFG FLEXCAN_HAS_BROKEN_ERR_STATE -> FLEXCAN_QUIRK_BROKEN_ERR_STATE FLEXCAN_HAS_MECR_FEATURES -> FLEXCAN_QUIRK_DISABLE_MECR Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2015-09-21can: flexcan: flexcan_chip_start(): cleanup writing of reg_mcrMarc Kleine-Budde1-4/+4
This patch changes the order the individual bits of the mcr register in flexcan_chip_start() are or'ed together to match the datasheet. The inline documentation is adjusted accordingly. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2015-09-21can: flexcan: remove unused header filesMarc Kleine-Budde1-4/+0
This patch removes unused header files from the flexcan driver. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2015-09-21can: flexcan: cleanup coding style and fix typosMarc Kleine-Budde1-52/+38
This patch fixes up the coding style to make checkpatch happier. Some typos are also fixed. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2015-08-20can: flexcan: demote register output to debug levelLucas Stach1-1/+1
This message isn't really helpful for the general reader of the kernel logs, so should not be printed with info level. All other register programming outputs in the flexcan driver already use the debug level. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2015-07-15can: flexcan: don't touch skb after netif_receive_skb()Marc Kleine-Budde1-4/+3
There is no guarantee that the skb is in the same state after calling net_receive_skb() or netif_rx(). It might be freed or reused. Not really harmful as its a read access, except you turn on the proper debugging options which catch a use after free. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2015-05-06can: flexcan: replace open coded "mailbox code" by proper defineMarc Kleine-Budde1-2/+1
This patch replaces a open coded variant of a "mailbox code" definition by an existing define, improves code readability. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2015-05-06can: flexcan: rename struct flexcan_regs::crl2 -> ctrl2Marc Kleine-Budde1-12/+12
This is done to mach the abbreviationin of the register in the datasheets. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2015-05-06can: flexcan: add documentation about mailbox organizationMarc Kleine-Budde1-0/+10
This patch adds a short documentation snippet about the mailbox organization as it's regularly not correct in freescale's datasheets. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2015-05-06can: flexcan: add MB/FIFO specific column to comment table of IP versionsDavid Jander1-8/+8
Flexcan V10 and newer are able to receive RTR frames in a MB. Older versions are not. Those should use flexcan in FIFO mode. Signed-off-by: David Jander <david@protonic.nl> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2015-03-22can: flexcan: Deferred on Regulator return EPROBE_DEFERAndreas Werner1-3/+8
Return EPROBE_DEFER if Regulator returns EPROBE_DEFER If the Flexcan driver is built into kernel and a regulator is used to enable the CAN transceiver, the Flexcan driver may not use the regulator. When initializing the Flexcan device with a regulator defined in the device tree, but not initialized, the regulator subsystem returns EPROBE_DEFER, hence the Flexcan init fails. The solution for this is to return EPROBE_DEFER if regulator is not initialized and wait until the regulator is initialized. Signed-off-by: Andreas Werner <kernel@andy89.org> Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2015-03-22can: flexcan: fix bus-off error state handling.Andri Yngvason1-4/+3
Making sure that the bus-off state gets passed to can_change_state(). Signed-off-by: Andri Yngvason <andri.yngvason@marel.com> Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2015-01-21can: flexcan: remove unused variableMarc Kleine-Budde1-2/+0
This patch removes the unused variable "struct net_device *dev" from the "struct flexcan_priv". Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>