summaryrefslogtreecommitdiff
path: root/drivers/net/can/m_can
AgeCommit message (Collapse)Author
2024-06-28can: m_can: Constify struct m_can_opsChristophe JAILLET
'struct m_can_ops' is not modified in these drivers. Constifying this structure moves some data to a read-only section, so increase overall security. On a x86_64, with allmodconfig, as an example: Before: ====== text data bss dec hex filename 4806 520 0 5326 14ce drivers/net/can/m_can/m_can_pci.o After: ===== text data bss dec hex filename 4862 464 0 5326 14ce drivers/net/can/m_can/m_can_pci.o Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Link: https://lore.kernel.org/all/a17b96d1be5341c11f263e1e45c9de1cb754e416.1719172843.git.christophe.jaillet@wanadoo.fr Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2024-06-21can: m_can: don't enable transceiver when probingMartin Hundebøll
The m_can driver sets and clears the CCCR.INIT bit during probe (both when testing the NON-ISO bit, and when configuring the chip). After clearing the CCCR.INIT bit, the transceiver enters normal mode, where it affects the CAN bus (i.e. it ACKs frames). This can cause troubles when the m_can node is only used for monitoring the bus, as one cannot setup listen-only mode before the device is probed. Rework the probe flow, so that the CCCR.INIT bit is only cleared when upping the device. First, the tcan4x5x driver is changed to stay in standby mode during/after probe. This in turn requires changes when setting bits in the CCCR register, as its CSR and CSA bits are always high in standby mode. Signed-off-by: Martin Hundebøll <martin@geanix.com> Reviewed-by: Markus Schneider-Pargmann <msp@baylibre.com> Tested-by: Markus Schneider-Pargmann <msp@baylibre.com> Link: https://lore.kernel.org/all/20240607105210.155435-1-martin@geanix.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2024-02-14can: tcan4x5x: support resuming from rx interrupt signalMartin Hundebøll
Implement the "wakeup-source" device tree property, so the chip is left running when suspending, and its rx interrupt is used as a wakeup source to resume operation. Signed-off-by: Martin Hundebøll <martin@geanix.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2024-02-14can: m_can: allow keeping the transceiver running in suspendMartin Hundebøll
Add a flag to the device class structure that leaves the chip in a running state with rx interrupt enabled, so that an m_can device driver can configure and use the interrupt as a wakeup source. Signed-off-by: Martin Hundebøll <martin@geanix.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2024-02-14can: m_can: remove redundant check for pm_clock_supportFrancesco Dolcini
m_can_clk_start() already skip starting the clock when clock support is disabled, remove the redundant check in m_can_class_register(). This also solves the imbalance with m_can_clk_stop() that is called afterward in the same function before the return. Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com> Reviewed-by: Markus Schneider-Pargmann <msp@baylibre.com> Link: https://lore.kernel.org/all/20240104235723.46931-1-francesco@dolcini.it [mkl: rebased to net-next/main] Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2024-02-12can: m_can: Implement transmit submission coalescingMarkus Schneider-Pargmann
m_can supports submitting multiple transmits with one register write. This is an interesting option to reduce the number of SPI transfers for peripheral chips. The m_can_tx_op is extended with a bool that signals if it is the last transmission and the submit should be executed immediately. The worker then writes the skb to the FIFO and submits it only if the submit bool is set. If it isn't set, the worker will write the next skb which is waiting in the workqueue to the FIFO, etc. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Link: https://lore.kernel.org/all/20240207093220.2681425-15-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2024-02-12can: m_can: Implement BQLMarkus Schneider-Pargmann
Implement byte queue limiting in preparation for the use of xmit_more(). Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Link: https://lore.kernel.org/all/20240207093220.2681425-14-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2024-02-12can: m_can: Use tx_fifo_in_flight for netif_queue controlMarkus Schneider-Pargmann
The network queue is currently always stopped in start_xmit and continued in the interrupt handler. This is not possible anymore if we want to keep multiple transmits in flight in parallel. Use the previously introduced tx_fifo_in_flight counter to control the network queue instead. This has the benefit of not needing to ask the hardware about fifo status. This patch stops the network queue in start_xmit if the number of transmits in flight reaches the size of the fifo and wakes up the queue from the interrupt handler once the transmits in flight drops below the fifo size. This means any skbs over the limit will be rejected immediately in start_xmit (it shouldn't be possible at all to reach that state anyways). The maximum number of transmits in flight is the size of the fifo. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Link: https://lore.kernel.org/all/20240207093220.2681425-13-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2024-02-12can: m_can: Introduce a tx_fifo_in_flight counterMarkus Schneider-Pargmann
Keep track of the number of transmits in flight. This patch prepares the driver to control the network interface queue based on this counter. By itself this counter be implemented with an atomic, but as we need to do other things in the critical sections later I am using a spinlock instead. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Link: https://lore.kernel.org/all/20240207093220.2681425-12-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2024-02-12can: m_can: Use the workqueue as queueMarkus Schneider-Pargmann
The current implementation uses the workqueue for peripheral chips to submit work. Only a single work item is queued and used at any time. To be able to keep more than one transmit in flight at a time, prepare the workqueue to support multiple transmits at the same time. Each work item now has a separate storage for a skb and a pointer to cdev. This assures that each workitem can be processed individually. The workqueue is replaced by an ordered workqueue which makes sure that only a single worker processes the items queued on the workqueue. Also items are ordered by the order they were enqueued. This removes most of the concurrency the workqueue normally offers. It is not necessary for this driver. The cleanup functions have to be adopted a bit to handle this new mechanism. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Link: https://lore.kernel.org/all/20240207093220.2681425-11-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2024-02-12can: m_can: Cache tx putidxMarkus Schneider-Pargmann
m_can_tx_handler is the only place where data is written to the tx fifo. We can calculate the putidx in the driver code here to avoid the dependency on the txfqs register. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Reviewed-by: Simon Horman <simon.horman@corigine.com> Link: https://lore.kernel.org/all/20240207093220.2681425-10-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2024-02-12can: m_can: Use u32 for putidxMarkus Schneider-Pargmann
putidx is not an integer normally, it is an unsigned field used in hardware registers. Use a u32 for it. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Reviewed-by: Simon Horman <simon.horman@corigine.com> Link: https://lore.kernel.org/all/20240207093220.2681425-9-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2024-02-12can: m_can: Add tx coalescing ethtool supportMarkus Schneider-Pargmann
Add TX support to get/set functions for ethtool coalescing. tx-frames-irq and tx-usecs-irq can only be set/unset together. tx-frames-irq needs to be less than TXE and TXB. As rx and tx share the same timer, rx-usecs-irq and tx-usecs-irq can be enabled/disabled individually but they need to have the same value if enabled. Polling is excluded from TX irq coalescing. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Reviewed-by: Simon Horman <horms@kernel.org> Reviewed-by: Simon Horman <simon.horman@corigine.com> Link: https://lore.kernel.org/all/20240207093220.2681425-8-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2024-02-12can: m_can: Add rx coalescing ethtool supportMarkus Schneider-Pargmann
Add the possibility to set coalescing parameters with ethtool. rx-frames-irq and rx-usecs-irq can only be set and unset together as the implemented mechanism would not work otherwise. rx-frames-irq can't be greater than the RX FIFO size. Also all values can only be changed if the chip is not active. Polling is excluded from irq coalescing support. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://lore.kernel.org/all/20240207093220.2681425-7-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2024-02-12can: m_can: Implement transmit coalescingMarkus Schneider-Pargmann
Extend the coalescing implementation for transmits. In normal mode the chip raises an interrupt for every finished transmit. This implementation switches to coalescing mode as soon as an interrupt handled a transmit. For coalescing the watermark level interrupt is used to interrupt exactly after x frames were sent. It switches back into normal mode once there was an interrupt with no finished transmit and the timer being inactive. The timer is shared with receive coalescing. The time for receive and transmit coalescing timers have to be the same for that to work. The benefit is to have only a single running timer. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://lore.kernel.org/all/20240207093220.2681425-6-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2024-02-12can: m_can: Implement receive coalescingMarkus Schneider-Pargmann
m_can offers the possibility to set an interrupt on reaching a watermark level in the receive FIFO. This can be used to implement coalescing. Unfortunately there is no hardware timeout available to trigger an interrupt if only a few messages were received within a given time. To solve this I am using a hrtimer to wake up the irq thread after x microseconds. The timer is always started if receive coalescing is enabled and new received frames were available during an interrupt. The timer is stopped if during a interrupt handling no new data was available. If the timer is started the new item interrupt is disabled and the watermark interrupt takes over. If the timer is not started again, the new item interrupt is enabled again, notifying the handler about every new item received. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Link: https://lore.kernel.org/all/20240207093220.2681425-5-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2024-02-12can: m_can: Write transmit header and data in one transactionMarkus Schneider-Pargmann
Combine header and data before writing to the transmit fifo to reduce the overhead for peripheral chips. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Reviewed-by: Simon Horman <simon.horman@corigine.com> Link: https://lore.kernel.org/all/20240207093220.2681425-4-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2024-02-12can: m_can: Move hrtimer init to m_can_class_registerMarkus Schneider-Pargmann
The hrtimer_init() is called in m_can_plat_probe() and the hrtimer function is set in m_can_class_register(). For readability it is better to keep these two together in m_can_class_register(). Cc: Judith Mendez <jm@ti.com> Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://lore.kernel.org/all/20240207093220.2681425-3-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2024-02-12can: m_can: Start/Cancel polling timer together with interruptsMarkus Schneider-Pargmann
Interrupts are enabled/disabled in more places than just m_can_start() and m_can_stop(). Couple the polling timer with enabling/disabling of all interrupts to achieve equivalent behavior. Cc: Judith Mendez <jm@ti.com> Fixes: b382380c0d2d ("can: m_can: Add hrtimer to generate software interrupt") Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://lore.kernel.org/all/20240207093220.2681425-2-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2023-10-06can: tcan4x5x: Fix id2_register for tcan4553Markus Schneider-Pargmann
Fix id2_register content for tcan4553. This slipped through my testing. Reported-by: Sean Anderson <sean.anderson@seco.com> Closes: https://lore.kernel.org/lkml/a94e6fc8-4f08-7877-2ba0-29b9c2780136@seco.com/ Fixes: 142c6dc6d9d7 ("can: tcan4x5x: Add support for tcan4552/4553") Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://lore.kernel.org/all/20230919095401.1312259-1-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2023-07-31can: tcan4x5x: Add error messages in probeMarkus Schneider-Pargmann
To be able to understand issues during probe easier, add error messages if something fails. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Link: https://lore.kernel.org/all/20230728141923.162477-7-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2023-07-31can: tcan4x5x: Add support for tcan4552/4553Markus Schneider-Pargmann
tcan4552 and tcan4553 do not have wake or state pins, so they are currently not compatible with the generic driver. The generic driver uses tcan4x5x_disable_state() and tcan4x5x_disable_wake() if the gpios are not defined. These functions use register bits that are not available in tcan4552/4553. This patch adds support by introducing version information to reflect if the chip has wake and state pins. Also the version is now checked. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Link: https://lore.kernel.org/all/20230728141923.162477-6-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2023-07-31can: tcan4x5x: Rename ID registers to match datasheetMarkus Schneider-Pargmann
The datasheet calls these registers ID1 and ID2. Rename these to avoid confusion. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Reviewed-by: Michal Kubiak <michal.kubiak@intel.com> Link: https://lore.kernel.org/all/20230728141923.162477-5-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2023-07-31can: tcan4x5x: Check size of mram configurationMarkus Schneider-Pargmann
To reduce debugging effort in case the mram is misconfigured, add this size check of the DT configuration. Currently if the mram configuration doesn't fit into the available MRAM it just overwrites other areas of the MRAM. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Reviewed-by: Michal Kubiak <michal.kubiak@intel.com> Link: https://lore.kernel.org/all/20230728141923.162477-4-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2023-07-31can: tcan4x5x: Remove reserved register 0x814 from writable tableMarkus Schneider-Pargmann
The mentioned register is not writable. It is reserved and should not be written. Fixes: 39dbb21b6a29 ("can: tcan4x5x: Specify separate read/write ranges") Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Reviewed-by: Michal Kubiak <michal.kubiak@intel.com> Link: https://lore.kernel.org/all/20230728141923.162477-3-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2023-07-28can: rx-offload: rename rx_offload_get_echo_skb() -> ↵Marc Kleine-Budde
can_rx_offload_get_echo_skb_queue_timestamp() Rename the rx_offload_get_echo_skb() function to can_rx_offload_get_echo_skb_queue_timestamp(), since it inserts the echo skb into the rx-offload queue sorted by timestamp. This is a preparation for adding can_rx_offload_get_echo_skb_queue_tail(), which adds the echo skb to the end of the queue. This is intended for devices that do not support timestamps. Link: https://lore.kernel.org/all/20230718-gs_usb-rx-offload-v2-1-716e542d14d5@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2023-07-28can: Explicitly include correct DT includes, part 2Rob Herring
The DT of_device.h and of_platform.h date back to the separate of_platform_bus_type before it as merged into the regular platform bus. As part of that merge prepping Arm DT support 13 years ago, they "temporarily" include each other. They also include platform_device.h and of.h. As a result, there's a pretty much random mix of those include files used throughout the tree. In order to detangle these headers and replace the implicit includes with struct declarations, users need to explicitly include the correct includes. Signed-off-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/all/20230724211841.805053-1-robh@kernel.org Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2023-07-17can: m_can: Add hrtimer to generate software interruptJudith Mendez
Introduce timer polling method to MCAN since some SoCs may not have M_CAN interrupt routed to A53 Linux and do not have interrupt property in device tree M_CAN node. On AM62x SoC, MCANs on MCU domain do not have hardware interrupt routed to A53 Linux, instead they will use timer polling method. Add an hrtimer to MCAN class device. Each MCAN will have its own hrtimer instantiated if there is no hardware interrupt found in device tree M_CAN node. The timer will generate a software interrupt every 1 ms. In hrtimer callback, we check if there is a transaction pending by reading a register, then process by calling the isr if there is. Tested-by: Hiago De Franco <hiago.franco@toradex.com> # Toradex Verdin AM62 Reviewed-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Judith Mendez <jm@ti.com> Link: https://lore.kernel.org/all/20230707204714.62964-3-jm@ti.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2023-06-22can: m_can: fix coding styleMarc Kleine-Budde
This patch aligns code to match open parenthesis and removes a trailing whitespace. Fixes: eb38c2053b67 ("can: rx-offload: rename can_rx_offload_queue_sorted() -> can_rx_offload_queue_timestamp()") Fixes: f5071d9e729d ("can: m_can: m_can_handle_bus_errors(): add support for handling DLEC error on CAN-FD frames") Reported-by: Judith Mendez <jm@ti.com> Link: https://lore.kernel.org/all/20230523062410.1984098-1-mkl@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2023-05-15can: m_can: Convert to platform remove callback returning voidUwe Kleine-König
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new() which already returns void. Eventually after all drivers are converted, .remove_new() is renamed to .remove(). Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20230512212725.143824-12-u.kleine-koenig@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2023-03-24can: m_can: Keep interrupts enabled during peripheral readMarkus Schneider-Pargmann
Interrupts currently get disabled if the interrupt status shows new received data. Non-peripheral chips handle receiving in a worker thread, but peripheral chips are handling the receive process in the threaded interrupt routine itself without scheduling it for a different worker. So there is no need to disable interrupts for peripheral chips. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Reviewed-by: Simon Horman <simon.horman@corigine.com> Link: https://lore.kernel.org/all/20230315110546.2518305-6-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2023-03-24can: m_can: Disable unused interruptsMarkus Schneider-Pargmann
There are a number of interrupts that are not used by the driver at the moment. Disable all of these. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Reviewed-by: Simon Horman <simon.horman@corigine.com> Link: https://lore.kernel.org/all/20230315110546.2518305-5-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2023-03-24can: m_can: Remove double interrupt enableMarkus Schneider-Pargmann
Interrupts are enabled a few lines further down as well. Remove this second call to enable all interrupts. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Reviewed-by: Simon Horman <simon.horman@corigine.com> Link: https://lore.kernel.org/all/20230315110546.2518305-4-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2023-03-24can: m_can: Always acknowledge all interruptsMarkus Schneider-Pargmann
The code already exits the function on !ir before this condition. No need to check again if anything is set as IR_ALL_INT is 0xffffffff. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Reviewed-by: Simon Horman <simon.horman@corigine.com> Link: https://lore.kernel.org/all/20230315110546.2518305-3-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2023-03-24can: m_can: Remove repeated check for is_peripheralMarkus Schneider-Pargmann
Merge both if-blocks to fix this. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Reviewed-by: Simon Horman <simon.horman@corigine.com> Link: https://lore.kernel.org/all/20230315110546.2518305-2-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2022-12-12can: tcan4x5x: Specify separate read/write rangesMarkus Schneider-Pargmann
Specify exactly which registers are read/writeable in the chip. This is supposed to help detect any violations in the future. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Link: https://lore.kernel.org/all/20221206115728.1056014-12-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2022-12-12can: tcan4x5x: Fix register range of first two blocksMarkus Schneider-Pargmann
According to the datasheet 0x10 is the last register in the first block, not register 0x2c. The datasheet lists the last register of the second block as 0x830, not 0x83c. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Link: https://lore.kernel.org/all/20221206115728.1056014-11-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2022-12-12can: tcan4x5x: Fix use of register error status maskMarkus Schneider-Pargmann
TCAN4X5X_ERROR_STATUS is not a status register that needs clearing during interrupt handling. Instead this is a masking register that masks error interrupts. Writing TCAN4X5X_CLEAR_ALL_INT to this register effectively masks everything. Rename the register and mask all error interrupts only once by writing to the register in tcan4x5x_init. Fixes: 5443c226ba91 ("can: tcan4x5x: Add tcan4x5x driver to the kernel") Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Link: https://lore.kernel.org/all/20221206115728.1056014-10-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2022-12-12can: tcan4x5x: Remove invalid write in clear_interruptsMarkus Schneider-Pargmann
Register 0x824 TCAN4X5X_MCAN_INT_REG is a read-only register. Any writes to this register do not have any effect. Remove this write. The m_can driver aldready clears the interrupts in m_can_isr() by writing to M_CAN_IR which is translated to register 0x1050 which is a writable version of this register. Fixes: 5443c226ba91 ("can: tcan4x5x: Add tcan4x5x driver to the kernel") Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Link: https://lore.kernel.org/all/20221206115728.1056014-9-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2022-12-12can: m_can: Batch acknowledge rx fifoMarkus Schneider-Pargmann
Instead of acknowledging every item of the fifo, only acknowledge the last item read. This behavior is documented in the datasheet. The new getindex will be the acknowledged item + 1. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Link: https://lore.kernel.org/all/20221206115728.1056014-8-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2022-12-12can: m_can: Batch acknowledge transmit eventsMarkus Schneider-Pargmann
Transmit events from the txe fifo can be batch acknowledged by acknowledging the last read txe fifo item. This will save txe_count writes which is important for peripheral chips. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Link: https://lore.kernel.org/all/20221206115728.1056014-7-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2022-12-12can: m_can: Count read getindex in the driverMarkus Schneider-Pargmann
The getindex gets increased by one every time. We can calculate the correct getindex in the driver and avoid the additional reads of rxfs. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Link: https://lore.kernel.org/all/20221206115728.1056014-6-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2022-12-12can: m_can: Count TXE FIFO getidx in the driverMarkus Schneider-Pargmann
The getindex simply increases by one for every iteration. There is no need to get the current getidx every time from a register. Instead we can just count and wrap if necessary. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Link: https://lore.kernel.org/all/20221206115728.1056014-5-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2022-12-12can: m_can: Read register PSR only on errorMarkus Schneider-Pargmann
Only read register PSR if there is an error indicated in irqstatus. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Link: https://lore.kernel.org/all/20221206115728.1056014-4-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2022-12-12can: m_can: Avoid reading irqstatus twiceMarkus Schneider-Pargmann
For peripheral devices the m_can_rx_handler is called directly after setting cdev->irqstatus. This means we don't have to read the irqstatus again in m_can_rx_handler. Avoid this by adding a parameter that is false for direct calls. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Link: https://lore.kernel.org/all/20221206115728.1056014-3-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2022-12-12can: m_can: Eliminate double read of TXFQS in tx_handlerMarkus Schneider-Pargmann
The TXFQS register is read first to check if the fifo is full and then immediately again to get the putidx. This is unnecessary and adds significant overhead if read requests are done over a slow bus, for example SPI with tcan4x5x. Add a variable to store the value of the register. Split the m_can_tx_fifo_full function into two to avoid the hidden m_can_read call if not needed. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Link: https://lore.kernel.org/all/20221206115728.1056014-2-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2022-12-12can: m_can: Call the RAM init directly from m_can_chip_configVivek Yadav
When we try to access the mcan message ram addresses during the probe, hclk is gated by any other drivers or disabled, because of that probe gets failed. Move the mram init functionality to mcan chip config called by m_can_start from mcan open function, by that time clocks are enabled. Suggested-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Vivek Yadav <vivek.2311@samsung.com> Link: https://lore.kernel.org/all/20221207100632.96200-2-vivek.2311@samsung.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2022-12-10can: m_can: sort header inclusion alphabeticallyVivek Yadav
Sort header inclusion alphabetically. Suggested-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Vivek Yadav <vivek.2311@samsung.com> Link: https://lore.kernel.org/all/20221104051617.21173-1-vivek.2311@samsung.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2022-11-29Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/netJakub Kicinski
tools/lib/bpf/ringbuf.c 927cbb478adf ("libbpf: Handle size overflow for ringbuf mmap") b486d19a0ab0 ("libbpf: checkpatch: Fixed code alignments in ringbuf.c") https://lore.kernel.org/all/20221121122707.44d1446a@canb.auug.org.au/ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2022-11-24can: m_can: Add check for devm_clk_getJiasheng Jiang
Since the devm_clk_get may return error, it should be better to add check for the cdev->hclk, as same as cdev->cclk. Fixes: f524f829b75a ("can: m_can: Create a m_can platform framework") Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn> Link: https://lore.kernel.org/all/20221123063651.26199-1-jiasheng@iscas.ac.cn Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>