summaryrefslogtreecommitdiff
path: root/drivers/net/can
Commit message (Collapse)AuthorAgeFilesLines
* Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/netJakub Kicinski2020-12-035-15/+20
|\ | | | | | | | | | | | | Conflicts: drivers/net/ethernet/ibm/ibmvnic.c Signed-off-by: Jakub Kicinski <kuba@kernel.org>
| * can: kvaser_pciefd: kvaser_pciefd_open(): fix error handlingZhang Qilong2020-11-301-1/+3
| | | | | | | | | | | | | | | | | | | | If kvaser_pciefd_bus_on() failed, we should call close_candev() to avoid reference leak. Fixes: 26ad340e582d3 ("can: kvaser_pciefd: Add driver for Kvaser PCIEcan devices") Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com> Link: https://lore.kernel.org/r/20201128133922.3276973-3-zhangqilong3@huawei.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
| * can: c_can: c_can_power_up(): fix error handlingZhang Qilong2020-11-301-4/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the error handling in c_can_power_up(), there are two bugs: 1) c_can_pm_runtime_get_sync() will increase usage counter if device is not empty. Forgetting to call c_can_pm_runtime_put_sync() will result in a reference leak here. 2) c_can_reset_ram() operation will set start bit when enable is true. We should clear it in the error handling. We fix it by adding c_can_pm_runtime_put_sync() for 1), and c_can_reset_ram(enable is false) for 2) in the error handling. Fixes: 8212003260c60 ("can: c_can: Add d_can suspend resume support") Fixes: 52cde85acc23f ("can: c_can: Add d_can raminit support") Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com> Link: https://lore.kernel.org/r/20201128133922.3276973-2-zhangqilong3@huawei.com [mkl: return "0" instead of "ret"] Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
| * can: sun4i_can: sun4i_can_err(): don't count arbitration lose as an errorJeroen Hofstee2020-11-301-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Losing arbitration is normal in a CAN-bus network, it means that a higher priority frame is being send and the pending message will be retried later. Hence most driver only increment arbitration_lost, but the sun4i driver also incremeants tx_error, causing errors to be reported on a normal functioning CAN-bus. So stop counting them as errors. Fixes: 0738eff14d81 ("can: Allwinner A10/A20 CAN Controller support - Kernel module") Signed-off-by: Jeroen Hofstee <jhofstee@victronenergy.com> Link: https://lore.kernel.org/r/20201127095941.21609-1-jhofstee@victronenergy.com [mkl: split into two seperate patches] Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
| * can: sja1000: sja1000_err(): don't count arbitration lose as an errorJeroen Hofstee2020-11-301-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Losing arbitration is normal in a CAN-bus network, it means that a higher priority frame is being send and the pending message will be retried later. Hence most driver only increment arbitration_lost, but the sja1000 driver also incremeants tx_error, causing errors to be reported on a normal functioning CAN-bus. So stop counting them as errors. Fixes: 8935f57e68c4 ("can: sja1000: fix network statistics update") Signed-off-by: Jeroen Hofstee <jhofstee@victronenergy.com> Link: https://lore.kernel.org/r/20201127095941.21609-1-jhofstee@victronenergy.com [mkl: split into two seperate patches] Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
| * can: m_can: tcan4x5x_can_probe(): fix error path: remove erroneous ↵Marc Kleine-Budde2020-11-301-8/+3
| | | | | | | | | | | | | | | | | | | | | | | | clk_disable_unprepare() The clocks mcan_class->cclk and mcan_class->hclk are not prepared by any call during tcan4x5x_can_probe(), so remove erroneous clk_disable_unprepare() on them. Fixes: 5443c226ba91 ("can: tcan4x5x: Add tcan4x5x driver to the kernel") Link: http://lore.kernel.org/r/20201130114252.215334-1-mkl@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: m_can: m_can_class_unregister(): move right after m_can_class_register()Marc Kleine-Budde2020-11-301-8/+8
| | | | | | | | | | | | | | | | | | This patch moves the function m_can_class_unregister() directly after the m_can_class_register() function. Link: https://lore.kernel.org/r/20201130133713.269256-7-mkl@pengutronix.de Reviewed-by: Dan Murphy <dmurphy@ti.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: m_can: m_can_plat_remove(): remove unneeded platform_set_drvdata()Marc Kleine-Budde2020-11-301-2/+0
| | | | | | | | | | | | | | | | | | There's no need to unset the drvdata on remove, so remove the unneeded call to platform_set_drvdata() in m_can_plat_remove(). Link: https://lore.kernel.org/r/20201130133713.269256-6-mkl@pengutronix.de Reviewed-by: Dan Murphy <dmurphy@ti.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: m_can: remove not used variable struct m_can_classdev::freqMarc Kleine-Budde2020-11-301-1/+0
| | | | | | | | | | | | | | | | This patch removes the unused variable freq from the struct m_can_classdev. Link: https://lore.kernel.org/r/20201130133713.269256-5-mkl@pengutronix.de Reviewed-by: Dan Murphy <dmurphy@ti.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: m_can: Kconfig: convert the into menuMarc Kleine-Budde2020-11-301-3/+5
| | | | | | | | | | | | | | | | | | Since there is more than one base driver for the m_can core, let's convert this into a menu. Link: https://lore.kernel.org/r/20201130133713.269256-4-mkl@pengutronix.de Reviewed-by: Dan Murphy <dmurphy@ti.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: tcan4x5x: tcan4x5x_can_probe(): remove probe failed error messageMarc Kleine-Budde2020-11-301-2/+0
| | | | | | | | | | | | | | | | | | The driver core already emits a probe failed error message, so remove this one from the driver. Link: https://lore.kernel.org/r/20201130133713.269256-3-mkl@pengutronix.de Reviewed-by: Dan Murphy <dmurphy@ti.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: tcan4x5x: remove mram_start and reg_offset from struct tcan4x5x_privMarc Kleine-Budde2020-11-301-10/+4
| | | | | | | | | | | | | | | | | | | | Both struct tcan4x5x_priv::mram_start and struct tcan4x5x_priv::reg_offset are only assigned once with a constant and then always used read-only. This patch changes the driver to use the constant directly instead. Link: https://lore.kernel.org/r/20201130133713.269256-2-mkl@pengutronix.de Reviewed-by: Dan Murphy <dmurphy@ti.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: tcan4x5x: rename parse_config() functionDan Murphy2020-11-301-2/+2
| | | | | | | | | | | | | | | | | | Rename the tcan4x5x_parse_config() function to tcan4x5x_get_gpios() since the function retrieves the gpio configurations from the firmware. Signed-off-by: Dan Murphy <dmurphy@ti.com> Link: http://lore.kernel.org/r/20200226140358.30017-1-dmurphy@ti.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: tcan4x5x: tcan4x5x_clear_interrupts(): remove redundant return statementSean Nyekjaer2020-11-291-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | This patch removes a redundant return at the end of tcan4x5x_clear_interrupts(). Signed-off-by: Sean Nyekjaer <sean@geanix.com> Link: http://lore.kernel.org/r/20191211141635.322577-1-sean@geanix.com Reported-by: Daniels Umanovskis <daniels@umanovskis.se> Acked-by: Dan Murphy <dmurphy@ti.com> Fixes: 5443c226ba91 ("can: tcan4x5x: Add tcan4x5x driver to the kernel") Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: mcp251xfd: tef-path: reduce number of SPI core requests to set UINC bitMarc Kleine-Budde2020-11-292-12/+55
| | | | | | | | | | | | | | | | | | Reduce the number of separate SPI core requests when setting the UINC bit in the TEF FIFO, and instead batch them up into a single SPI core request. Link: https://lore.kernel.org/r/20201126132144.351154-6-mkl@pengutronix.de Tested-by: Thomas Kopp <thomas.kopp@microchip.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: mcp251xfd: move struct mcp251xfd_tef_ring definitionMarc Kleine-Budde2020-11-291-8/+8
| | | | | | | | | | | | | | | | | | This patch moves the struct mcp251xfd_tef_ring upwards, so that the union mcp251xfd_write_reg_buf and struct spi_transfer can be made members of it. Link: https://lore.kernel.org/r/20201126132144.351154-5-mkl@pengutronix.de Tested-by: Thomas Kopp <thomas.kopp@microchip.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: mcp251xfd: struct mcp251xfd_priv::tef to array of length 1Marc Kleine-Budde2020-11-292-12/+14
| | | | | | | | | | | | | | | | | | | | This patch converts the struct mcp251xfd_tef_ring member within the struct mcp251xfd_priv into an array of length one. This way all rings (tef, tx and rx) can be accessed in the same way. Link: https://lore.kernel.org/r/20201126132144.351154-4-mkl@pengutronix.de Tested-by: Thomas Kopp <thomas.kopp@microchip.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: mcp25xxfd: rx-path: reduce number of SPI core requests to set UINC bitUrsula Maplehurst2020-11-292-8/+45
| | | | | | | | | | | | | | | | | | | | | | Reduce the number of separate SPI core requests when setting the UINC bit in the RX FIFO, and instead batch them up into a single SPI core request. Link: https://github.com/marckleinebudde/linux/issues/4 Link: https://lore.kernel.org/r/20201126132144.351154-3-mkl@pengutronix.de Tested-by: Thomas Kopp <thomas.kopp@microchip.com> Signed-off-by: Ursula Maplehurst <ursula@kangatronix.co.uk> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: mcp251xfd: mcp25xxfd_ring_alloc(): add define instead open coding the ↵Marc Kleine-Budde2020-11-292-1/+3
| | | | | | | | | | | | | | | | | | | | | | maximum number of RX objects This patch add a define for the maximum number of RX objects instead of open coding it. Link: https://lore.kernel.org/r/20201126132144.351154-2-mkl@pengutronix.de Tested-by: Thomas Kopp <thomas.kopp@microchip.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: pcan_usb_core: fix fall-through warnings for ClangGustavo A. R. Silva2020-11-291-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by moving the "default" to the end of the "switch" statement and explicitly adding a break statement instead of letting the code fall through to the next case. Link: https://github.com/KSPP/linux/issues/115 Reported-by: Gustavo A. R. Silva <gustavoars@kernel.org> Link: http://lore.kernel.org/r/aab7cf16bf43cc7c3e9c9930d2dae850c1d07a3c.1605896059.git.gustavoars@kernel.org Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> [mkl: move default to end] Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/netJakub Kicinski2020-11-273-63/+78
|\ \ | |/ | | | | | | | | | | | | | | Trivial conflict in CAN, keep the net-next + the byteswap wrapper. Conflicts: drivers/net/can/usb/gs_usb.c Signed-off-by: Jakub Kicinski <kuba@kernel.org>
| * can: m_can: m_can_dev_setup(): add support for bosch mcan version 3.3.0Pankaj Sharma2020-11-271-0/+2
| | | | | | | | | | | | | | | | | | | | Add support for mcan bit timing and control mode according to bosch mcan IP version 3.3.0. The mcan version read from the Core Release field of CREL register would be 33. Accordingly the properties are to be set for mcan v3.3.0 Signed-off-by: Pankaj Sharma <pankj.sharma@samsung.com> Link: https://lore.kernel.org/r/1606366302-5520-1-git-send-email-pankj.sharma@samsung.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
| * can: m_can: fix nominal bitiming tseg2 min for version >= 3.1Marc Kleine-Budde2020-11-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At lest the revision 3.3.0 of the bosch m_can IP core specifies that valid register values for "Nominal Time segment after sample point (NTSEG2)" are from 1 to 127. As the hardware uses a value of one more than the programmed value, mean tseg2_min is 2. This patch fixes the tseg2_min value accordingly. Cc: Dan Murphy <dmurphy@ti.com> Cc: Mario Huettel <mario.huettel@gmx.net> Acked-by: Sriram Dash <sriram.dash@samsung.com> Link: https://lore.kernel.org/r/20201124190751.3972238-1-mkl@pengutronix.de Fixes: b03cfc5bb0e1 ("can: m_can: Enable M_CAN version dependent initialization") Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
| * can: m_can: m_can_open(): remove IRQF_TRIGGER_FALLING from ↵Marc Kleine-Budde2020-11-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | request_threaded_irq()'s flags The threaded IRQ handler is used for the tcan4x5x driver only. The IRQ pin of the tcan4x5x controller is active low, so better not use IRQF_TRIGGER_FALLING when requesting the IRQ. As this can result in missing interrupts. Further, if the device tree specified the interrupt as "IRQ_TYPE_LEVEL_LOW", unloading and reloading of the driver results in the following error during ifup: | irq: type mismatch, failed to map hwirq-31 for gpio@20a8000! | tcan4x5x spi1.1: m_can device registered (irq=0, version=32) | tcan4x5x spi1.1 can2: TCAN4X5X successfully initialized. | tcan4x5x spi1.1 can2: failed to request interrupt This patch fixes the problem by removing the IRQF_TRIGGER_FALLING from the request_threaded_irq(). Fixes: f524f829b75a ("can: m_can: Create a m_can platform framework") Cc: Dan Murphy <dmurphy@ti.com> Cc: Sriram Dash <sriram.dash@samsung.com> Cc: Pankaj Sharma <pankj.sharma@samsung.com> Link: https://lore.kernel.org/r/20201127093548.509253-1-mkl@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
| * can: mcp251xfd: mcp251xfd_probe(): bail out if no IRQ was givenMarc Kleine-Budde2020-11-261-0/+4
| | | | | | | | | | | | | | | | | | | | | | This patch add a check to the mcp251xfd_probe() function to bail out and give the user a proper error message if no IRQ is specified. Otherwise the driver will probe just fine but ifup will fail with a meaningless "RTNETLINK answers: Invalid argument" error message. Link: https://lore.kernel.org/r/20201123113522.3820052-1-mkl@pengutronix.de Reported-by: Niels Petter <petter@ka-long.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
| * can: gs_usb: fix endianess problem with candleLight firmwareMarc Kleine-Budde2020-11-261-61/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The firmware on the original USB2CAN by Geschwister Schneider Technologie Entwicklungs- und Vertriebs UG exchanges all data between the host and the device in host byte order. This is done with the struct gs_host_config::byte_order member, which is sent first to indicate the desired byte order. The widely used open source firmware candleLight doesn't support this feature and exchanges the data in little endian byte order. This breaks if a device with candleLight firmware is used on big endianess systems. To fix this problem, all u32 (but not the struct gs_host_frame::echo_id, which is a transparent cookie) are converted to __le32. Cc: Maximilian Schneider <max@schneidersoft.net> Cc: Hubert Denkmair <hubert@denkmair.de> Reported-by: Michael Rausch <mr@netadair.de> Link: https://lore.kernel.org/r/b58aace7-61f3-6df7-c6df-69fee2c66906@netadair.de Tested-by: Oleksij Rempel <o.rempel@pengutronix.de> Fixes: d08e973a77d1 ("can: gs_usb: Added support for the GS_USB CAN devices") Link: https://lore.kernel.org/r/20201120103818.3386964-1-mkl@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | net: don't include ethtool.h from netdevice.hJakub Kicinski2020-11-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | linux/netdevice.h is included in very many places, touching any of its dependecies causes large incremental builds. Drop the linux/ethtool.h include, linux/netdevice.h just needs a forward declaration of struct ethtool_ops. Fix all the places which made use of this implicit include. Acked-by: Johannes Berg <johannes@sipsolutions.net> Acked-by: Shannon Nelson <snelson@pensando.io> Reviewed-by: Jesse Brandeburg <jesse.brandeburg@intel.com> Link: https://lore.kernel.org/r/20201120225052.1427503-1-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* | can: mcp251xfd: remove useless code in mcp251xfd_chip_softresetKaixu Xia2020-11-201-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | It would directly return if the variable err equals to 0 or other errors. Only when the err equals to -ETIMEDOUT it can reach the 'if (err)' statement, so the 'if (err)' and last 'return -ETIMEDOUT' statements are useless. Romove them. Reported-by: Tosk Robot <tencent_os_robot@tencent.com> Signed-off-by: Kaixu Xia <kaixuxia@tencent.com> Link: https://lore.kernel.org/r/1605605352-25298-1-git-send-email-kaixuxia@tencent.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: kvaser_usb: Add new Kvaser hydra devicesJimmy Assarsson2020-11-202-1/+10
| | | | | | | | | | | | | | | | Add new Kvaser hydra devices. Signed-off-by: Jimmy Assarsson <extja@kvaser.com> Link: https://lore.kernel.org/r/20201115163027.16851-6-jimmyassarsson@gmail.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: kvaser_usb: kvaser_usb_hydra: Add support for new device variantChrister Beskow2020-11-201-0/+37
| | | | | | | | | | | | | | | | | | | | Add support for a new variant of devices using the hydra platform, based on NXP i.MX RT (flexcan). Signed-off-by: Christer Beskow <chbe@kvaser.com> Signed-off-by: Jimmy Assarsson <extja@kvaser.com> Link: https://lore.kernel.org/r/20201115163027.16851-5-jimmyassarsson@gmail.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: kvaser_usb: Add new Kvaser Leaf v2 devicesJimmy Assarsson2020-11-202-1/+9
| | | | | | | | | | | | | | | | Add new Kvaser Leaf v2 devices. Signed-off-by: Jimmy Assarsson <extja@kvaser.com> Link: https://lore.kernel.org/r/20201115163027.16851-4-jimmyassarsson@gmail.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: kvaser_usb: Add USB_{LEAF,HYDRA}_PRODUCT_ID_END definesJimmy Assarsson2020-11-201-2/+6
| | | | | | | | | | | | | | | | | | | | Add USB_{LEAF,HYDRA}_PRODUCT_ID_END defines, representing the last USB PID entry in respectively family. This removes the need to update the kvaser_is_{leaf,hydra}() functions whenever new devices are added. Signed-off-by: Jimmy Assarsson <extja@kvaser.com> Link: https://lore.kernel.org/r/20201115163027.16851-3-jimmyassarsson@gmail.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: flexcan: flexcan_close(): change order if commands to properly shut ↵Marc Kleine-Budde2020-11-201-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | down the controller There haven been reports, that the flexcan_close() soradically hangs during simultanious ifdown, sending of CAN messages and probably open CAN bus: | (__schedule) from [<808bbd34>] (schedule+0x90/0xb8) | (schedule) from [<808bf274>] (schedule_timeout+0x1f8/0x24c) | (schedule_timeout) from [<8016be44>] (msleep+0x18/0x1c) | (msleep) from [<80746a64>] (napi_disable+0x60/0x70) | (napi_disable) from [<8052fdd0>] (flexcan_close+0x2c/0x140) | (flexcan_close) from [<80744930>] (__dev_close_many+0xb8/0xd8) | (__dev_close_many) from [<8074db9c>] (__dev_change_flags+0xd0/0x1a0) | (__dev_change_flags) from [<8074dc84>] (dev_change_flags+0x18/0x48) | (dev_change_flags) from [<80760c24>] (do_setlink+0x44c/0x7b4) | (do_setlink) from [<80761560>] (rtnl_newlink+0x374/0x68c) I was unable to reproduce the issue, but a cleanup of the flexcan close sequence has probably fixed the problem at the reporting user. This patch changes the sequence in flexcan_close() to: - stop the TX queue - disable the interrupts on the chip level and wait via free_irq() synchronously for the interrupt handler to finish - disable RX offload, which disables synchronously NAPI - disable the flexcan on the chip level - free RX offload - disable the transceiver - close the CAN device - disable the clocks Link: https://lore.kernel.org/r/20201119100917.3013281-6-mkl@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: flexcan: flexcan_open(): completely initialize controller before ↵Marc Kleine-Budde2020-11-201-10/+11
| | | | | | | | | | | | | | | | | | | | | | requesting IRQ This patch changes the order in which the flexcan controller is brought up during flexcan_open(). It makes sure that the chip is completely initialized before the IRQs are requested and finally enabled. Link: https://lore.kernel.org/r/20201119100917.3013281-5-mkl@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: flexcan: flexcan_rx_offload_setup(): factor out mailbox and rx-offload ↵Marc Kleine-Budde2020-11-201-32/+42
| | | | | | | | | | | | | | | | | | | | setup into separate function In an upcoming patch the order of operations in flexcan_open() are changed. Introduce convenience function to make that patch simpler. Link: https://lore.kernel.org/r/20201119100917.3013281-4-mkl@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: flexcan: move enabling/disabling of interrupts from ↵Marc Kleine-Budde2020-11-201-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | flexcan_chip_{start,stop}() to callers The function flexcan_chip_start() first configures the CAN controller and then enables the interrupt, flexcan_chip_stop() does the opposite. In an upcoming patch the order of operations in flexcan_open() and flexcan_close() are changed. This requires flexcan_chip_start()/flexcan_chip_stop_disable_on_error() and flexcan_chip_interrupts_{enable,disable}() to be independent of each other. This patch moves the enabling of the interrupts from flexcan_chip_start() to its callers flexcan_open() and flexcan_resume(). Likewise the disabling of the interrupts is moved from __flexcan_chip_stop() to its indirect callers flexcan_close() and flexcan_suspend(). Link: https://lore.kernel.org/r/20201119100917.3013281-3-mkl@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: flexcan: factor out enabling and disabling of interrupts into separate ↵Marc Kleine-Budde2020-11-201-14/+27
| | | | | | | | | | | | | | | | | | | | function The upcoming patches are going to move the enabling and disabling of the interrupts. Introduce convenience functions to make these patches simpler. Link: https://lore.kernel.org/r/20201119100917.3013281-2-mkl@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: flexcan: rename macro FLEXCAN_QUIRK_SETUP_STOP_MODE -> ↵Joakim Zhang2020-11-201-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR This patch intends to rename FLEXCAN_QUIRK_SETUP_STOP_MODE quirk to FLEXCAN_QUIRK_SETUP_STOP_MODE_GRP for non-scu SoCs, coming patch will add quirk for scu SoCs. For non-scu SoCs, setup stop mode with GPR register. For scu SoCs, setup stop mode with SCU firmware. Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com> Link: https://lore.kernel.org/r/20201106105627.31061-4-qiangqing.zhang@nxp.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: drivers: add len8_dlc support for esd_usb2 CAN adapterStefan Mätje2020-11-201-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Support the Classical CAN raw DLC functionality to send and receive DLC values from 9 .. 15 for the Classical CAN capable CAN network driver esd_usb that supports the esd CAN-USB/2 and CAN-USB/Micro devices: - esd_usb2 Signed-off-by: Stefan Mätje <stefan.maetje@esd.eu> Tested-by: Stefan Mätje <stefan.maetje@esd.eu> Link: https://lore.kernel.org/r/20201116184430.25462-2-stefan.maetje@esd.eu [mkl: rewrapped some long lines] Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: drivers: add len8_dlc support for various CAN adaptersOliver Hartkopp2020-11-205-23/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Support the Classical CAN raw DLC functionality to send and receive DLC values from 9 .. 15 on various Classical CAN capable CAN network drivers: - sja1000 - gs_usb - pcan_usb - pcan_usb_fd - usb_8dev Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net> Tested-by: Oliver Hartkopp <socketcan@hartkopp.net> Link: https://lore.kernel.org/r/20201111095923.2535-1-socketcan@hartkopp.net [mkl: usb_8dev: changed indention] Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: rename CAN FD related can_len2dlc and can_dlc2len helpersOliver Hartkopp2020-11-2011-29/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The helper functions can_len2dlc and can_dlc2len are only relevant for CAN FD data length code (DLC) conversion. To fit the introduced can_cc_dlc2len for Classical CAN we rename: can_dlc2len -> can_fd_dlc2len to get the payload length from the DLC can_len2dlc -> can_fd_len2dlc to get the DLC from the payload length Suggested-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net> Link: https://lore.kernel.org/r/20201110101852.1973-6-socketcan@hartkopp.net Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: replace can_dlc as variable/element for payload lengthOliver Hartkopp2020-11-2036-222/+222
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The naming of can_dlc as element of struct can_frame and also as variable name is misleading as it claims to be a 'data length CODE' but in reality it always was a plain data length. With the indroduction of a new 'len' element in struct can_frame we can now remove can_dlc as name and make clear which of the former uses was a plain length (-> 'len') or a data length code (-> 'dlc') value. Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net> Link: https://lore.kernel.org/r/20201120100444.3199-1-socketcan@hartkopp.net [mkl: gs_usb: keep struct gs_host_frame::can_dlc as is] Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: remove obsolete get_canfd_dlc() macroOliver Hartkopp2020-11-205-5/+5
| | | | | | | | | | | | | | | | | | The macro was always used together with can_dlc2len() which sanitizes the given dlc value on its own. Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net> Link: https://lore.kernel.org/r/20201110101852.1973-4-socketcan@hartkopp.net Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | can: rename get_can_dlc() macro with can_cc_dlc2len()Oliver Hartkopp2020-11-2031-41/+41
| | | | | | | | | | | | | | | | | | | | | | | | The get_can_dlc() macro is used to ensure the payload length information of the Classical CAN frame to be max 8 bytes (the CAN_MAX_DLEN). Rename the macro and use the correct constant in preparation of the len/dlc cleanup for Classical CAN frames. Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net> Link: https://lore.kernel.org/r/20201110101852.1973-3-socketcan@hartkopp.net Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
* | Merge https://git.kernel.org/pub/scm/linux/kernel/git/netdev/netJakub Kicinski2020-11-1912-48/+86
|\ \ | |/ | | | | Signed-off-by: Jakub Kicinski <kuba@kernel.org>
| * can: m_can: process interrupt only when not runtime suspendedJarkko Nikula2020-11-181-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Avoid processing bogus interrupt statuses when the HW is runtime suspended and the M_CAN_IR register read may get all bits 1's. Handler can be called if the interrupt request is shared with other peripherals or at the end of free_irq(). Therefore check the runtime suspended status before processing. Fixes: cdf8259d6573 ("can: m_can: Add PM Support") Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Link: https://lore.kernel.org/r/20200915134715.696303-1-jarkko.nikula@linux.intel.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
| * can: flexcan: flexcan_chip_start(): fix erroneous ↵Marc Kleine-Budde2020-11-181-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | flexcan_transceiver_enable() during bus-off recovery If the CAN controller goes into bus off, the do_set_mode() callback with CAN_MODE_START can be used to recover the controller, which then calls flexcan_chip_start(). If configured, this is done automatically by the framework or manually by the user. In flexcan_chip_start() there is an explicit call to flexcan_transceiver_enable(), which does a regulator_enable() on the transceiver regulator. This results in a net usage counter increase, as there is no corresponding flexcan_transceiver_disable() in the bus off code path. This further leads to the transceiver stuck enabled, even if the CAN interface is shut down. To fix this problem the flexcan_transceiver_enable()/flexcan_transceiver_disable() are moved out of flexcan_chip_start()/flexcan_chip_stop() into flexcan_open()/flexcan_close(). Fixes: e955cead0311 ("CAN: Add Flexcan CAN controller driver") Link: https://lore.kernel.org/r/20201118150148.2664024-1-mkl@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
| * can: kvaser_usb: kvaser_usb_hydra: Fix KCAN bittiming limitsJimmy Assarsson2020-11-181-1/+1
| | | | | | | | | | | | | | | | | | Use correct bittiming limits for the KCAN CAN controller. Fixes: aec5fb2268b7 ("can: kvaser_usb: Add support for Kvaser USB hydra family") Signed-off-by: Jimmy Assarsson <extja@kvaser.com> Link: https://lore.kernel.org/r/20201115163027.16851-2-jimmyassarsson@gmail.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
| * can: kvaser_pciefd: Fix KCAN bittiming limitsJimmy Assarsson2020-11-181-2/+2
| | | | | | | | | | | | | | | | | | Use correct bittiming limits for the KCAN CAN controller. Fixes: 26ad340e582d ("can: kvaser_pciefd: Add driver for Kvaser PCIEcan devices") Signed-off-by: Jimmy Assarsson <extja@kvaser.com> Link: https://lore.kernel.org/r/20201115163027.16851-1-jimmyassarsson@gmail.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
| * can: m_can: m_can_stop(): set device to software init mode before closingFaiz Abbas2020-11-151-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | There might be some requests pending in the buffer when the interface close sequence occurs. In some devices, these pending requests might lead to the module not shutting down properly when m_can_clk_stop() is called. Therefore, move the device to init state before potentially powering it down. Fixes: e0d1f4816f2a ("can: m_can: add Bosch M_CAN controller support") Signed-off-by: Faiz Abbas <faiz_abbas@ti.com> Acked-by: Dan Murphy <dmurphy@ti.com> Link: https://lore.kernel.org/r/20200825055442.16994-1-faiz_abbas@ti.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>