summaryrefslogtreecommitdiff
path: root/drivers/net/can/flexcan.c
AgeCommit message (Collapse)Author
2015-06-16Test patch: Enable CAN SoC level loopbackBhupesh Sharma
This patch enables the SoC level CAN loopback. Signed-off-by: Bhupesh Sharma <bhupesh.sharma@freescale.com> Change-Id: I5efd40f5d853d11b2476b2bbab0db66c7b1711fa Reviewed-on: http://git.am.freescale.net:8181/38097 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com>
2015-06-16can: flexcan: Add support for non RX-FIFO modeBhupesh Sharma
This patch adds support for non RX-FIFO (legacy) mode in the flexcan driver. On certain SoCs, the RX-FIFO support might be broken, as a result we need to fall-back on the legacy (non RX-FIFO) mode to receive CAN frames. Signed-off-by: Bhupesh Sharma <bhupesh.sharma@freescale.com> Signed-off-by: Sakar Arora <Sakar.Arora@freescale.com> Change-Id: I8b07e851b68fcca9716d02b14b6712c2da654ad5 Reviewed-on: http://git.am.freescale.net:8181/38095 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com>
2015-06-16can: flexcan: Remodel FlexCAN register r/w APIs for BE instancesBhupesh Sharma
The FlexCAN IP on certain SoCs like (Freescale's LS1021A) is modelled in a big-endian fashion, i.e. the registers and the message buffers are organized in a BE way. More details about the LS1021A SoC can be seen here: http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=LS1021A&nodeId=018rH325E4017B# This patch ensures that the register read/write APIs are remodelled to address such cases, while ensuring that existing platforms (where the FlexCAN IP was modelled in LE way) do not break. Tested on LS1021A-QDS board. Signed-off-by: Bhupesh Sharma <bhupesh.sharma@freescale.com> Signed-off-by: Sakar Arora <Sakar.Arora@freescale.com> Change-Id: I4116956dfc92ae565a2aea96356014c77f506c1c Reviewed-on: http://git.am.freescale.net:8181/38094 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com>
2015-06-16can: flexcan: Add ls1021a flexcan device entryBhupesh Sharma
This patch adds ls1021a flexcan device entry to the flexcan driver code. Signed-off-by: Bhupesh Sharma <bhupesh.sharma@freescale.com> Change-Id: Iad4f7caf7be878784414d194335f203ea02743e5 Reviewed-on: http://git.am.freescale.net:8181/38093 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com>
2015-06-16Revert 'can: flexcan: Add ls1021a flexcan device entry'Bhupesh Sharma
This reverts commit 61af51e63ff5a3666788b1c5c2d42c3df3a03c34. Signed-off-by: Bhupesh Sharma <bhupesh.sharma@freescale.com> Change-Id: I196e1fbc30a97ae0102b13eddd25bdf9230e02f4 Reviewed-on: http://git.am.freescale.net:8181/38091 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com>
2015-06-16Revert 'net: can: Remodel FlexCAN register read/write APIs for BE instances'Bhupesh Sharma
This reverts commit 4966cbb525a2acfb7c2782f1994949e97b45f242. Signed-off-by: Bhupesh Sharma <bhupesh.sharma@freescale.com> Change-Id: Ifec4963a1ed01fb60f949575e1c2be4da5c38cf6 Reviewed-on: http://git.am.freescale.net:8181/38090 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com>
2015-06-16Revert 'can: flexcan: Add support for non RX-FIFO mode and conditional ↵Bhupesh Sharma
ERRATA ERR005829 handling' This reverts commit 0ec580b6a604a4fcfd65c3515459def643c8517a. Signed-off-by: Bhupesh Sharma <bhupesh.sharma@freescale.com> Change-Id: I64fb32407f7083aa433d4d7ec34d7171c2bdc02b Reviewed-on: http://git.am.freescale.net:8181/38089 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com>
2014-12-11can: flexcan: Add support for non RX-FIFO mode and conditional ERRATA ↵Bhupesh Sharma
ERR005829 handling This patch adds support for non RX-FIFO (legacy) mode and conditional ERRATA ERR005829 handling in flexcan driver. Both these features are now selectable via Kconfig entries and hence can be turned-on/off as per a SoC feature set availability. Signed-off-by: Bhupesh Sharma <bhupesh.sharma@freescale.com> Change-Id: I2a5a4970b7e5b18a45fb421f1c0d008ad5a3b0f8 Reviewed-on: http://git.am.freescale.net:8181/21856 Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com> Tested-by: Zhengxiong Jin <Jason.Jin@freescale.com>
2014-12-11net: can: Remodel FlexCAN register read/write APIs for BE instancesBhupesh Sharma
The FlexCAN IP on certain SoCs like (Freescale's LS1021A) is modelled in a big-endian fashion, i.e. the registers and the message buffers are organized in a BE way. More details about the LS1021A SoC can be seen here: http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=LS1021A&nodeId=018rH325E4017B# This patch ensures that the register read/write APIs are remodelled to address such cases, while ensuring that existing platforms (where the FlexCAN IP was modelled in LE way) do not break. Tested on LS1021A-QDS board. Signed-off-by: Bhupesh Sharma <bhupesh.sharma@freescale.com> Change-Id: Ibaa6b1816670537466b227b5032be73338435c03 Reviewed-on: http://git.am.freescale.net:8181/21854 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com>
2014-12-11can: flexcan: Add ls1021a flexcan device entryBhupesh Sharma
This patch adds ls1021a flexcan device entry to the flexcan driver code. Signed-off-by: Bhupesh Sharma <bhupesh.sharma@freescale.com> --- Previous version of this patch under review upstream: http://patchwork.ozlabs.org/patch/363588/ Change-Id: Ie01ec4583e1dc4efd90eb05e69ed45ae351d9d4e Reviewed-on: http://git.am.freescale.net:8181/21853 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com>
2014-12-11[fsl-only] can: flexcan: Remove can_change_mtu calls as this is not ↵Bhupesh Sharma
supported in 3.12 kernel Signed-off-by: Bhupesh Sharma <bhupesh.sharma@freescale.com> Change-Id: I731e457b0b29a794c752116921b119c37514758a Reviewed-on: http://git.am.freescale.net:8181/21852 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com>
2014-12-11can: flexcan: increase FLEXCAN_MCR_MAXMB() macro to 7 bitsMarc Kleine-Budde
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> --- Cherry-picked from linux-next: 4c728d804c4b9d1ae7f76e8f32c419bc21a6e540 Change-Id: If7f3817dced00e4864da29579ff377788e9ee4ad Reviewed-on: http://git.am.freescale.net:8181/21851 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com>
2014-12-11can: flexcan: put TX mailbox into TX_INACTIVE mode after tx-completeMarc Kleine-Budde
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> --- Cherry-picked from linux-next: de5944883ebbedbf5adc8497659772f5da7b7d72 Change-Id: Icfa9443f03246feee26868b9ad17147b2352c9fd Reviewed-on: http://git.am.freescale.net:8181/21850 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com>
2014-12-11can: flexcan: implement workaround for errata ERR005829David Jander
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> --- Cherry-picked from linux-next: 25e924450fcb23c11c07c95ea8964dd9f174652e Change-Id: I504198f3b5aaba2c0277b596e925ce3bb17a2258 Reviewed-on: http://git.am.freescale.net:8181/21849 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com>
2014-12-11can: flexcan: correctly initialize mailboxesBhupesh Sharma
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> --- Cherry-picked from linux-next: fc05b884a31dbf259cc73cc856e634ec3acbebb6 Change-Id: I0757258cb27cb2dec26e8afa219b512bba80be4b Reviewed-on: http://git.am.freescale.net:8181/21848 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com>
2014-12-11can: flexcan: mark TX mailbox as TX_INACTIVEMarc Kleine-Budde
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> --- Cherry-picked from linux-next: c32fe4ad3e4861b2bfa1f44114c564935a123dda Change-Id: I3058828c8f0786726589a8fc05a5cc8467644e1b Reviewed-on: http://git.am.freescale.net:8181/21847 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com>
2014-12-11can: flexcan: avoid calling usleep_range from interrupt contextDavid Jander
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> --- Cherry-picked from linux-next: 8badd65e48c90d66587359d5329c2813088c0f50 Change-Id: I44fef82e8b413d6751a23fcb05d4a9f39ecb385a Reviewed-on: http://git.am.freescale.net:8181/21846 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com>
2014-12-11can: flexcan: handle state passive -> warning transitionSebastian Andrzej Siewior
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> --- Cherry-picked from linux-next: 8ce261d0bb491da957278cdcba207791f329d1da Change-Id: I311a7075033b493ef06818fb1e15f0eb69e96fa2 Reviewed-on: http://git.am.freescale.net:8181/21845 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com>
2014-12-11can: flexcan: Disable error interrupt when bus error reporting is disabledAlexander Stein
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> --- Cherry-picked from linux-next: bc03a54139baafcd8fe89ad115411c2c9c8a4905 Change-Id: Ieb52a8f0cc761a37faf4556284bf2c922c6bec79 Reviewed-on: http://git.am.freescale.net:8181/21844 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com>
2014-12-11can: flexcan: add vf610 support for FlexCANStefan Agner
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> --- Cherry-picked from linux-next: cdce844865bea6869b34bacc98af3711774f5bb5 Change-Id: I296ab822a5e2ed6e28b98e348d690eab8ec165ac Reviewed-on: http://git.am.freescale.net:8181/21843 Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com> Tested-by: Zhengxiong Jin <Jason.Jin@freescale.com>
2014-12-11can: flexcan: flexcan_get_berr_counter(): switch on clocks before accessing ↵Stefan Agner
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> --- Cherry-picked from linux-next: ec56acfef2af184ca485ffeba16adbd56c110c94 Change-Id: I53ead04b0d5ae7c995809c51aef57acaedd3c3f4 Reviewed-on: http://git.am.freescale.net:8181/21842 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com>
2014-12-11can: Unify MTU settings for CAN interfacesOliver Hartkopp
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> --- Cherry-picked from linux-next: c971fa2ae42e73e9ccc2f5e93f268c8742da4c5d Change-Id: I933a13a6c1f0b65fa748ffca352fa061940d8893 Reviewed-on: http://git.am.freescale.net:8181/21841 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com>
2014-12-11can: flexcan: make use of platform_get_device_id()Marc Kleine-Budde
This patch replaces an open coded pdev->id_entry by platform_get_device_id(). Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> --- Cherry-picked from linux-next: d0873e6fc06686cf2dfb9adabb6ca65e9967c60f Change-Id: I4a70c813dd5ce60b0c81cc57aa41a78413a891a0 Reviewed-on: http://git.am.freescale.net:8181/21840 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com>
2014-12-11can: flexcan: Remove #ifdef CONFIG_PM_SLEEPMarc Kleine-Budde
This patch removes #ifdef CONFIG_PM_SLEEP to improve compile coverage. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> --- Cherry-picked from linux-next: 08c6d35154069becb01243176fb72b3bc60ff3cb Change-Id: I062083cf2a38d7b3dfa2c9a3329c843ed6c91cf8 Reviewed-on: http://git.am.freescale.net:8181/21839 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com>
2014-12-11can: flexcan: factor out soft reset into seperate funtionMarc Kleine-Budde
This patch moves the soft reset into a seperate function. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> --- Cherry-picked from Linux-next: 4b5b82274a17f0ebbf02378df2ba7f36a3f5af19 Change-Id: I52b4dabb58e6b9af6b5a1825bb20d40d0a8a91a7 Reviewed-on: http://git.am.freescale.net:8181/21838 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com>
2014-12-11can: flexcan: fix transition from and to freeze mode in chip_{,un}freezeMarc Kleine-Budde
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> --- Cherry-picked from linux-next: b1aa1c7a2165b44ecce66286a3095cc6c7667d1c Change-Id: I0db4998dab8782d717a99eebb6d3a56ed787bbde Reviewed-on: http://git.am.freescale.net:8181/21837 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com>
2014-03-24can: flexcan: flexcan_remove(): add missing netif_napi_del()Marc Kleine-Budde
commit d96e43e8fce28cf97df576a07af9d65657a41a6f upstream. This patch adds the missing netif_napi_del() to the flexcan_remove() function. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
2014-03-24can: flexcan: factor out transceiver {en,dis}able into seperate functionsMarc Kleine-Budde
commit f003698e23f6f56a791774f14d0ac35d04872490 upstream. This patch moves the transceiver enable and disable into seperate functions, where the NULL pointer check is hidden. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
2014-03-24can: flexcan: fix transition from and to low power mode in chip_{en,dis}ableMarc Kleine-Budde
commit 9b00b300e7bce032c467c36ca47fe2a776887fc2 upstream. 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. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
2014-03-24can: flexcan: flexcan_open(): fix error path if flexcan_chip_start() failsMarc Kleine-Budde
commit 7e9e148af01ef388efb6e2490805970be4622792 upstream. If flexcan_chip_start() in flexcan_open() fails, the interrupt is not freed, this patch adds the missing cleanup. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
2014-03-24can: flexcan: fix shutdown: first disable chip, then all interruptsMarc Kleine-Budde
commit 5be93bdda64e85450598c6e97f79fb8f6acf30e0 upstream. 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. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
2013-12-12can: flexcan: use correct clock as base for bit rate calculationMarc Kleine-Budde
commit 1a3e5173f5e72cbf7f0c8927b33082e361c16d72 upstream. 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. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-10-09can: flexcan: fix mx28 detection by rearanging OF match tableMarc Kleine-Budde
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-09can: flexcan: flexcan_chip_start: fix regression, mark one MB for TX and ↵Marc Kleine-Budde
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-09-30can: flexcan: fix flexcan_chip_start() on imx6Marc Kleine-Budde
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-08-22can: flexcan: use platform_set_drvdata()Libo Chen
Use the wrapper functions for getting and setting the driver data using platform_device instead of using dev_set_drvdata() with &pdev->dev, so we can directly pass a struct platform_device. Signed-off-by: Libo Chen <libo.chen@huawei.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2013-08-01can: flexcan: Check the return value from clk_prepare_enable()Fabio Estevam
clk_prepare_enable() may fail, so let's check its return value and propagate it in the case of error. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2013-08-01can: flexcan: Use devm_ioremap_resource()Fabio Estevam
Using devm_ioremap_resource() can make the code simpler and smaller. Also, place alloc_candev() after of_match_device() to make error handling easier. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2013-06-27can: flexcan: Use a regulator to control the CAN transceiverFabio Estevam
Instead of using a GPIO to turn on/off the CAN transceiver, it is better to use a regulator as some systems may use a PMIC to power the CAN transceiver. Acked-by: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2013-06-03can: flexcan: Use SIMPLE_DEV_PM_OPSFabio Estevam
Using SIMPLE_DEV_PM_OPS can make the code smaller and simpler. Also change CONFIG_PM to CONFIG_PM_SLEEP. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2013-06-03can: flexcan: Let device core handle pinctrlFabio Estevam
Since commit ab78029 (drivers/pinctrl: grab default handles from device core) we can rely on device core for handling pinctrl, so remove devm_pinctrl_get_select_default() from the driver. Cc: Marc Kleine-Budde <mkl@pengutronix.de> Cc: <linux-can@vger.kernel.org> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2013-05-16net: can: flexcan: remove unnecessary platform_set_drvdata()Jingoo Han
The driver core clears the driver data to NULL after device_release or on probe failure, since commit 0998d0631001288a5974afc0b2a5f568bcdecb4d (device-core: Ensure drvdata = NULL when no driver is bound). Thus, it is not needed to manually clear the device driver data to NULL. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2013-01-26can: flexcan: add LED trigger supportFabio Baltieri
Add support for canbus activity led indicators on flexcan devices by calling appropriate can_led_* functions. These are only enabled when CONFIG_CAN_LEDS is Y, becomes no-op otherwise. Cc: Oliver Hartkopp <socketcan@hartkopp.net> Cc: Wolfgang Grandegger <wg@grandegger.com> Cc: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2012-12-03can: remove __dev* attributesBill Pemberton
CONFIG_HOTPLUG is going away as an option. As result the __dev* markings will be going away. Remove use of __devinit, __devexit_p, __devinitdata, __devinitconst, and __devexit. Signed-off-by: Bill Pemberton <wfp5p@virginia.edu> Cc: Wolfgang Grandegger <wg@grandegger.com> Cc: Marc Kleine-Budde <mkl@pengutronix.de> Cc: linux-can@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-27can: flexcan: add MODULE_DEVICE_TABLEMarc Kleine-Budde
This patch adds a MODULE_DEVICE_TABLE for the of and platform bindings, so that the module can be loaded automatically by udev. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2012-10-23can: flexcan: disable bus error interrupts for the i.MX6qWolfgang Grandegger
This patch adds some Flexcan version info and removes the feature flag FLEXCAN_HAS_BROKEN_ERR_STATE for the i.MX6Q. It also has the line [TR]WRN_INT properly connected. Cc: Hui Wang <jason77.wang@gmail.com> Cc: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Wolfgang Grandegger <wg@grandegger.com> [mkl: convert to incremental patch] Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2012-10-01flexcan: disable bus error interrupts for the i.MX28Wolfgang Grandegger
Due to a bug in most Flexcan cores, the bus error interrupt needs to be enabled. Otherwise we don't get any error warning or passive interrupts. This is _not_ necessary for the i.MX28 and this patch disables bus error interrupts if "berr-reporting" is not requested. This avoids bus error flooding, which might harm, especially on low-end systems. To handle such quirks of the Flexcan cores, a hardware feature flag has been introduced, also replacing the "hw_ver" variable. So far nobody could tell what Flexcan core version is available on what Freescale SOC, apart from the i.MX6Q and P1010, and which bugs or features are present on the various "hw_rev". CC: Hui Wang <jason77.wang@gmail.com> CC: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Wolfgang Grandegger <wg@grandegger.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2012-07-20can: flexcan: add 2nd clock to support imx53 and newerSteffen Trumtrar
This patch adds support for a second clock to the flexcan driver. On modern freescale ARM cores like the imx53 and imx6q two clocks ("ipg" and "per") must be enabled in order to access the CAN core. In the original driver, the clock was requested without specifying the connection id, further all mainline ARM archs with flexcan support (imx28, imx25, imx35) register their flexcan clock without a connection id, too. This patch first renames the existing clk variable to clk_ipg and converts it to devm for easier error handling. The connection id "ipg" is added to the devm_clk_get() call. Then a second clock "per" is requested. As all archs don't specify a connection id, both clk_get return the same clock. This ensures compatibility to existing flexcan support and adds support for imx53 at the same time. After this patch hits mainline, the archs may give their existing flexcan clock the "ipg" connection id and implement a dummy "per" clock. This patch has been tested on imx28 (unmodified clk tree) and on imx53 with a seperate "ipg" and "per" clock. Cc: Sascha Hauer <s.hauer@pengutronix.de> Cc: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Acked-by: Hui Wang <jason77.wang@gmail.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2012-07-20can: mark bittiming_const pointer in struct can_priv as constMarc Kleine-Budde
This patch marks the bittiming_const pointer as in the struct can_pric as "const". This allows us to mark the struct can_bittiming_const in the CAN drivers as "const", too. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2012-07-17can: flexcan: make flexcan_priv.devtype_data member point to const dataMarc Kleine-Budde
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>