summaryrefslogtreecommitdiff
path: root/drivers/net/can/flexcan.c
AgeCommit message (Collapse)AuthorFilesLines
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 ↵Marc Kleine-Budde1-21/+21
address space 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-22can: 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>
2014-12-15Merge tag 'driver-core-3.19-rc1' of ↵Linus Torvalds1-1/+0
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core Pull driver core update from Greg KH: "Here's the set of driver core patches for 3.19-rc1. They are dominated by the removal of the .owner field in platform drivers. They touch a lot of files, but they are "simple" changes, just removing a line in a structure. Other than that, a few minor driver core and debugfs changes. There are some ath9k patches coming in through this tree that have been acked by the wireless maintainers as they relied on the debugfs changes. Everything has been in linux-next for a while" * tag 'driver-core-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (324 commits) Revert "ath: ath9k: use debugfs_create_devm_seqfile() helper for seq_file entries" fs: debugfs: add forward declaration for struct device type firmware class: Deletion of an unnecessary check before the function call "vunmap" firmware loader: fix hung task warning dump devcoredump: provide a one-way disable function device: Add dev_<level>_once variants ath: ath9k: use debugfs_create_devm_seqfile() helper for seq_file entries ath: use seq_file api for ath9k debugfs files debugfs: add helper function to create device related seq_file drivers/base: cacheinfo: remove noisy error boot message Revert "core: platform: add warning if driver has no owner" drivers: base: support cpu cache information interface to userspace via sysfs drivers: base: add cpu_device_create to support per-cpu devices topology: replace custom attribute macros with standard DEVICE_ATTR* cpumask: factor out show_cpumap into separate helper function driver core: Fix unbalanced device reference in drivers_probe driver core: fix race with userland in device_add() sysfs/kernfs: make read requests on pre-alloc files use the buffer. sysfs/kernfs: allow attributes to request write buffer be pre-allocated. fs: sysfs: return EGBIG on write if offset is larger than file size ...
2014-12-07can: flexcan: Consolidate and unify state change handlingAndri Yngvason1-83/+18
Replacing error state change handling with the new mechanism. Signed-off-by: Andri Yngvason <andri.yngvason@marel.com> Acked-by: Wolfgang Grandegger <wg@grandegger.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-10-20net: can: drop owner assignment from platform_driversWolfram Sang1-1/+0
A platform_driver does not need to set an owner, it will be populated by the driver core. Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2014-09-23Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/netDavid S. Miller1-10/+44
Conflicts: arch/mips/net/bpf_jit.c drivers/net/can/flexcan.c Both the flexcan and MIPS bpf_jit conflicts were cases of simple overlapping changes. Signed-off-by: David S. Miller <davem@davemloft.net>
2014-09-18can: flexcan: increase FLEXCAN_MCR_MAXMB() macro to 7 bitsMarc Kleine-Budde1-1/+1
This patch increases the mask in the FLEXCAN_MCR_MAXMB() to 7 bits as in the newer flexcan cores the MAXMB field is 7 bits wide. Reported-by: David Jander <david@protonic.nl> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-09-18can: flexcan: put TX mailbox into TX_INACTIVE mode after tx-completeMarc Kleine-Budde1-0/+3
After sending a RTR frame the TX mailbox becomes a RX_EMPTY mailbox. To avoid side effects when the RX-FIFO is full, this patch puts the TX mailbox into TX_INACTIVE mode in the transmission complete interrupt handler. This, of course, leaves a race window between the actual completion of the transmission and the handling of tx-complete interrupt. However this is the best we can do without busy polling the tx complete interrupt. Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-09-18can: flexcan: implement workaround for errata ERR005829David Jander1-1/+15
This patch implements the workaround mentioned in ERR005829: ERR005829: FlexCAN: FlexCAN does not transmit a message that is enabled to be transmitted in a specific moment during the arbitration process. Workaround: The workaround consists of two extra steps after setting up a message for transmission: Step 8: Reserve the first valid mailbox as an inactive mailbox (CODE=0b1000). If RX FIFO is disabled, this mailbox must be message buffer 0. Otherwise, the first valid mailbox can be found using the "RX FIFO filters" table in the FlexCAN chapter of the chip reference manual. Step 9: Write twice INACTIVE code (0b1000) into the first valid mailbox. Signed-off-by: David Jander <david@protonic.nl> Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-09-18can: flexcan: correctly initialize mailboxesDavid Jander1-0/+7
Apparently mailboxes may contain random data at startup, causing some of them being prepared for message reception. This causes overruns being missed or even confusing the IRQ check for trasmitted messages, increasing the transmit counter instead of the error counter. This patch initializes all mailboxes after the FIFO as RX_INACTIVE. Signed-off-by: David Jander <david@protonic.nl> Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-09-18can: flexcan: mark TX mailbox as TX_INACTIVEMarc Kleine-Budde1-2/+13
This patch fixes the initialization of the TX mailbox. It is now correctly initialized as TX_INACTIVE not RX_EMPTY. Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-09-11can: flexcan: avoid calling usleep_range from interrupt contextDavid Jander1-5/+5
Apparently can_restart() runs from a (timer-) interrupt and can call flexcan_chip_[en|dis]able(), so avoid using usleep_range() Signed-off-by: David Jander <david@protonic.nl> Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-08-23Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/netDavid S. Miller1-0/+9
Pulling to get some TIPC fixes that a net-next series depends upon. Signed-off-by: David S. Miller <davem@davemloft.net>
2014-08-21can: flexcan: handle state passive -> warning transitionSebastian Andrzej Siewior1-0/+7
Once the CAN-bus is open and a packet is sent, the controller switches into the PASSIVE state. Once the BUS is closed again it goes the back err-warning. The TX error counter goes 0 -> 0x80 -> 0x7f. This patch makes sure that the user learns about this state chang (CAN_STATE_ERROR_WARNING => CAN_STATE_ERROR_PASSIVE) Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Matthias Klein <matthias.klein@optimeas.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-08-21can: flexcan: Disable error interrupt when bus error reporting is disabledAlexander Stein1-0/+2
In case we don't have FLEXCAN_HAS_BROKEN_ERR_STATE and the user set CAN_CTRLMODE_BERR_REPORTING once it can not be unset again until reboot. So in case neither hardware nor user wants the error interrupt disable the bit. Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-08-18can: flexcan: add vf610 support for FlexCANStefan Agner1-10/+71
Extend FlexCAN driver to support Vybrid. Vybrids variant of the IP has ECC support which is controlled through the memory error control register (MECR). There is also an errata which leads to false positive error detections (ID e5295). This patch disables the memory error detection completely. Signed-off-by: Stefan Agner <stefan@agner.ch> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-08-18can: flexcan: flexcan_get_berr_counter(): switch on clocks before accessing ↵Stefan Agner1-3/+27
ecr register The funcion flexcan_get_berr_counter() may be called from userspace even if the interface is down, this the clocks are disabled. This patch switches on the clocks before accessing the ecr register. Reported-by: Ashutosh Singh <ashuleapyear@gmail.com> Signed-off-by: Stefan Agner <stefan@agner.ch> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-03-17can: Unify MTU settings for CAN interfacesOliver Hartkopp1-0/+1
CAN interfaces only support MTU values of 16 (CAN 2.0) and 72 (CAN FD). Setting the MTU to other values is pointless but it does not really hurt. With the introduction of the CAN FD support in drivers/net/can a new function to switch the MTU for CAN FD has been introduced. This patch makes use of this can_change_mtu() function to check for correct MTU settings also in legacy CAN (2.0) devices. Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-03-07can: flexcan: make use of platform_get_device_id()Marc Kleine-Budde1-2/+2
This patch replaces an open coded pdev->id_entry by platform_get_device_id(). Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-03-07can: flexcan: Remove #ifdef CONFIG_PM_SLEEPMarc Kleine-Budde1-4/+2
This patch removes #ifdef CONFIG_PM_SLEEP to improve compile coverage. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-03-03can: flexcan: factor out soft reset into seperate funtionMarc Kleine-Budde1-9/+17
This patch moves the soft reset into a seperate function. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-03-03can: flexcan: flexcan_remove(): add missing netif_napi_del()Marc Kleine-Budde1-1/+2
This patch adds the missing netif_napi_del() to the flexcan_remove() function. Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-03-03can: flexcan: fix transition from and to freeze mode in chip_{,un}freezeMarc Kleine-Budde1-11/+49
This patch factors out freeze and unfreeze of the CAN core into seperate functions. Experiments have shown that the transition from and to freeze mode may take several microseconds, especially the time entering the freeze mode depends on the current bitrate. This patch adds a while loop which polls the Freeze Mode ACK bit (FRZ_ACK) that indicates a successfull mode change. If the function runs into a timeout a error value is returned. Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-03-03can: flexcan: factor out transceiver {en,dis}able into seperate functionsMarc Kleine-Budde1-7/+20
This patch moves the transceiver enable and disable into seperate functions, where the NULL pointer check is hidden. Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-03-03can: flexcan: fix transition from and to low power mode in chip_{en,dis}ableMarc Kleine-Budde1-12/+38
In flexcan_chip_enable() and flexcan_chip_disable() fixed delays are used. Experiments have shown that the transition from and to low power mode may take several microseconds. This patch adds a while loop which polls the Low Power Mode ACK bit (LPM_ACK) that indicates a successfull mode change. If the function runs into a timeout a error value is returned. Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-03-03can: flexcan: flexcan_open(): fix error path if flexcan_chip_start() failsMarc Kleine-Budde1-1/+3
If flexcan_chip_start() in flexcan_open() fails, the interrupt is not freed, this patch adds the missing cleanup. Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-03-03can: flexcan: fix shutdown: first disable chip, then all interruptsMarc Kleine-Budde1-3/+5
When shutting down the CAN interface (ifconfig canX down) during high CAN bus loads, the CAN core might hang and freeze the whole CPU. This patch fixes the shutdown sequence by first disabling the CAN core then disabling all interrupts. Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-01-29can: flexcan: fix flexcan driver build for big endian on ARM and little ↵Arnd Bergmann1-2/+5
endian on PowerPc There is no reason to disallow building the driver on big-endian ARM kernels. Furthermore, the current behavior is actually broken on little-endian PowerPC as well. The choice of register accessor functions must purely depend on the CPU architecture, not which endianess the CPU is running on. Note that we nowadays allow both big-endian ARM and little-endian PowerPC kernels. With this patch applied, we will do the right thing in all four combinations. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Cc: Guenter Roeck <linux@roeck-us.net> Cc: Lothar Waßmann <LW@KARO-electronics.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2013-11-26can: flexcan: use correct clock as base for bit rate calculationMarc Kleine-Budde1-1/+1
The flexcan IP core uses the peripheral clock ("per") as basic clock for the bit timing calculation. However the driver uses the the wrong clock ("ipg"). This leads to wrong bit rates if the rates on both clock are different. This patch fixes the problem by using the correct clock for the bit rate calculation. Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2013-10-24Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/netDavid S. Miller1-4/+10
Conflicts: drivers/net/usb/qmi_wwan.c include/net/dst.h Trivial merge conflicts, both were overlapping changes. Signed-off-by: David S. Miller <davem@davemloft.net>
2013-10-10can: flexcan: fix mx28 detection by rearanging OF match tableMarc Kleine-Budde1-2/+2
The current implemetation of of_match_device() relies that the of_device_id table in the driver is sorted from most specific to least specific compatible. Without this patch the mx28 is detected as the less specific p1010. This leads to a p1010 specific workaround is activated on the mx28, which is not needed. Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2013-10-10can: flexcan: flexcan_chip_start: fix regression, mark one MB for TX and ↵Marc Kleine-Budde1-2/+8
abort pending TX In patch 0d1862e can: flexcan: fix flexcan_chip_start() on imx6 the loop in flexcan_chip_start() that iterates over all mailboxes after the soft reset of the CAN core was removed. This loop put all mailboxes (even the ones marked as reserved 1...7) into EMPTY/INACTIVE mode. On mailboxes 8...63, this aborts any pending TX messages. After a cold boot there is random garbage in the mailboxes, which leads to spontaneous transmit of CAN frames during first activation. Further if the interface was disabled with a pending message (usually due to an error condition on the CAN bus), this message is retransmitted after enabling the interface again. This patch fixes the regression by: 1) Limiting the maximum number of used mailboxes to 8, 0...7 are used by the RX FIFO, 8 is used by TX. 2) Marking the TX mailbox as EMPTY/INACTIVE, so that any pending TX of that mailbox is aborted. Cc: linux-stable <stable@vger.kernel.org> Cc: Lothar Waßmann <LW@KARO-electronics.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2013-10-02Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/netDavid S. Miller1-12/+0
Conflicts: drivers/net/ethernet/emulex/benet/be.h drivers/net/usb/qmi_wwan.c drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h include/net/netfilter/nf_conntrack_synproxy.h include/net/secure_seq.h The conflicts are of two varieties: 1) Conflicts with Joe Perches's 'extern' removal from header file function declarations. Usually it's an argument signature change or a function being added/removed. The resolutions are trivial. 2) Some overlapping changes in qmi_wwan.c and be.h, one commit adds a new value, another changes an existing value. That sort of thing. Signed-off-by: David S. Miller <davem@davemloft.net>
2013-09-30can: flexcan: fix flexcan_chip_start() on imx6Marc Kleine-Budde1-12/+0
In the flexcan_chip_start() function first the flexcan core is going through the soft reset sequence, then the RX FIFO is enabled. With the hardware is put into FIFO mode, message buffers 1...7 are reserved by the FIFO engine. The remaining message buffers are in reset default values. This patch removes the bogus initialization of the message buffers, as it causes an imprecise external abort on imx6. Cc: linux-stable <stable@vger.kernel.org> Reported-by: Lothar Waßmann <LW@KARO-electronics.de> Tested-by: Lothar Waßmann <LW@KARO-electronics.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2013-09-21can: flexcan: use dev_get_platdata()Jingoo Han1-1/+1
Use the wrapper function for retrieving the platform data instead of accessing dev->platform_data directly. This is a cosmetic change to make the code simpler and enhance the readability. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>