pull-request: can-next 2022-12-12
Subsystems (12)
Marc Kleine-Budde
maintainercover pull-request: can-next 2022-12-12
Hello Jakub, hello David,
this is a pull request of 39 patches for net-next/master.
The first 2 patches are by me fix a warning and coding style in the kvaser_usb driver.
Vivek Yadav's patch sorts the includes of the m_can driver.
Biju Das contributes 5 patches for the rcar_canfd driver improve the support for different IP core variants.
Jean Delvare's patch for the ctucanfd drops the dependency on COMPILE_TEST.
Vincent Mailhol's patch sorts the includes of the etas_es58x driver.
Haibo Chen's contributes 2 patches that add i.MX93 support to the flexcan driver.
Lad Prabhakar's patch updates the dt-bindings documentation of the rcar_canfd driver.
Minghao Chi's patch converts the c_can platform driver to devm_platform_get_and_ioremap_resource().
In the next 7 patches Vincent Mailhol adds devlink support to the etas_es58x driver to report firmware, bootloader and hardware version.
Xu Panda's patch converts a strncpy() -> strscpy() in the ucan driver.
Ye Bin's patch removes a useless parameter from the AF_CAN protocol.
The next 2 patches by Vincent Mailhol and remove unneeded or unused pointers to struct usb_interface in device's priv struct in the ucan and gs_usb driver.
Vivek Yadav's patch cleans up the usage of the RAM initialization in the m_can driver.
A patch by me add support for SO_MARK to the AF_CAN protocol.
Geert Uytterhoeven's patch fixes the number of CAN channels in the rcan_canfd bindings documentation.
In the last 11 patches Markus Schneider-Pargmann optimizes the register access in the t_can driver and cleans up the tcan glue driver.
regards,
Marc
---
The following changes since commit dd8b3a802b64adf059a49a68f1bdca7846e492fc:
Merge tag 'ipsec-next-2022-12-09' of git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec-next (2022-12-09 20:06:35 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git tags/linux-can-next-for-6.2-20221212
for you to fetch changes up to 47bf2b2393ea1aacdefbe4e9d643599e057bb3a2:
Merge patch series "can: m_can: Optimizations for tcan and peripheral chips" (2022-12-12 12:01:26 +0100)
----------------------------------------------------------------
linux-can-next-for-6.2-20221212
----------------------------------------------------------------
Biju Das (5):
can: rcar_canfd: rcar_canfd_probe: Add struct rcar_canfd_hw_info to driver data
can: rcar_canfd: Add max_channels to struct rcar_canfd_hw_info
can: rcar_canfd: Add shared_global_irqs to struct rcar_canfd_hw_info
can: rcar_canfd: Add postdiv to struct rcar_canfd_hw_info
can: rcar_canfd: Add multi_channel_irqs to struct rcar_canfd_hw_info
Geert Uytterhoeven (1):
dt-bindings: can: renesas,rcar-canfd: Fix number of channels for R-Car V3U
Haibo Chen (2):
can: flexcan: add auto stop mode for IMX93 to support wakeup
dt-bindings: can: fsl,flexcan: add imx93 compatible
Jean Delvare (1):
can: ctucanfd: Drop obsolete dependency on COMPILE_TEST
Lad Prabhakar (1):
dt-bindings: can: renesas,rcar-canfd: Document RZ/Five SoC
Marc Kleine-Budde (7):
can: kvaser_usb: kvaser_usb_set_bittiming(): fix redundant initialization warning for err
can: kvaser_usb: kvaser_usb_set_{,data}bittiming(): remove empty lines in variable declaration Merge patch series "R-Car CAN FD driver enhancements"
Merge patch series "can: etas_es58x: report firmware, bootloader and hardware version" Merge patch series "can: usb: remove pointers to struct usb_interface in device's priv structures"
can: raw: add support for SO_MARK
Merge patch series "can: m_can: Optimizations for tcan and peripheral chips"
Markus Schneider-Pargmann (11):
can: m_can: Eliminate double read of TXFQS in tx_handler
can: m_can: Avoid reading irqstatus twice
can: m_can: Read register PSR only on error
can: m_can: Count TXE FIFO getidx in the driver
can: m_can: Count read getindex in the driver
can: m_can: Batch acknowledge transmit events
can: m_can: Batch acknowledge rx fifo
can: tcan4x5x: Remove invalid write in clear_interrupts
can: tcan4x5x: Fix use of register error status mask
can: tcan4x5x: Fix register range of first two blocks
can: tcan4x5x: Specify separate read/write ranges
Minghao Chi (1):
can: c_can: use devm_platform_get_and_ioremap_resource()
Vincent Mailhol (10):
can: etas_es58x: sort the includes by alphabetic order
can: etas_es58x: add devlink support
can: etas_es58x: add devlink port support
USB: core: export usb_cache_string()
net: devlink: add DEVLINK_INFO_VERSION_GENERIC_FW_BOOTLOADER
can: etas_es58x: export product information through devlink_ops::info_get()
can: etas_es58x: remove es58x_get_product_info()
Documentation: devlink: add devlink documentation for the etas_es58x driver
can: ucan: remove unused ucan_priv::intf
can: gs_usb: remove gs_can::iface
Vivek Yadav (2):
can: m_can: sort header inclusion alphabetically
can: m_can: Call the RAM init directly from m_can_chip_config
Xu Panda (1):
can: ucan: use strscpy() to instead of strncpy()
Ye Bin (1):
net: af_can: remove useless parameter 'err' in 'can_rx_register()'
.../devicetree/bindings/net/can/fsl,flexcan.yaml | 1 + .../bindings/net/can/renesas,rcar-canfd.yaml | 135 ++++++------ Documentation/networking/devlink/devlink-info.rst | 5 + Documentation/networking/devlink/etas_es58x.rst | 36 ++++ MAINTAINERS | 1 + drivers/net/can/c_can/c_can_platform.c | 3 +- drivers/net/can/ctucanfd/Kconfig | 2 +- drivers/net/can/flexcan/flexcan-core.c | 37 +++- drivers/net/can/flexcan/flexcan.h | 2 + drivers/net/can/m_can/m_can.c | 130 ++++++++---- drivers/net/can/m_can/m_can.h | 16 +- drivers/net/can/m_can/m_can_platform.c | 6 +- drivers/net/can/m_can/tcan4x5x-core.c | 18 +- drivers/net/can/m_can/tcan4x5x-regmap.c | 47 ++++- drivers/net/can/rcar/rcar_canfd.c | 85 +++++--- drivers/net/can/usb/Kconfig | 1 + drivers/net/can/usb/etas_es58x/Makefile | 2 +- drivers/net/can/usb/etas_es58x/es581_4.c | 4 +- drivers/net/can/usb/etas_es58x/es58x_core.c | 104 ++++----- drivers/net/can/usb/etas_es58x/es58x_core.h | 58 ++++- drivers/net/can/usb/etas_es58x/es58x_devlink.c | 235 +++++++++++++++++++++ drivers/net/can/usb/etas_es58x/es58x_fd.c | 4 +- drivers/net/can/usb/gs_usb.c | 29 +-- drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c | 4 +- drivers/net/can/usb/ucan.c | 7 +- drivers/usb/core/message.c | 1 + drivers/usb/core/usb.h | 1 - include/linux/usb.h | 1 + include/net/devlink.h | 2 + net/can/af_can.c | 3 +- net/can/raw.c | 1 + 31 files changed, 696 insertions(+), 285 deletions(-) create mode 100644 Documentation/networking/devlink/etas_es58x.rst create mode 100644 drivers/net/can/usb/etas_es58x/es58x_devlink.c
Marc Kleine-Budde
maintainerPATCH 1/39 can: kvaser_usb: kvaser_usb_set_bittiming(): fix redundant initialization warning for err
The variable err is initialized, but the initialized value is Overwritten before it is read. Fix the warning by not initializing the variable err at all.
--- drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c +1 -1
@@ -541,7 +541,7 @@ static int kvaser_usb_set_bittiming(struct net_device *netdev)int tseg1 = bt->prop_seg + bt->phase_seg1;int tseg2 = bt->phase_seg2;int sjw = bt->sjw; -int err = -EOPNOTSUPP ; +int err; busparams.bitrate =cpu_to_le32 (bt->bitrate); busparams.sjw = (u8 )sjw;
base-commit: dd8b3a802b64adf059a49a68f1bdca7846e492fc
Signature · 1 line
2.35.1
Re: [PATCH net-next 01/39] can: kvaser_usb: kvaser_usb_set_bittiming(): fix redundant initialization warning for err
This series was applied to netdev/net-next.git (master) by Marc Kleine-Budde <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (master) by Marc Kleine-Budde <[email protected]>:
Quoted 11 lines · On Mon, 12 Dec 2022 12:30:07 +0100 you wrote:
The variable err is initialized, but the initialized value is Overwritten before it is read. Fix the warning by not initializing the variable err at all.
Fixes 39d3df6b0ea8 ("can: kvaser_usb: Compare requested bittiming parameters with actual parameters in do_set_{,data}_bittiming")Cc Jimmy Assarsson <[email protected]>Cc Anssi Hannula <[email protected]>Signed-off-by Marc Kleine-Budde <[email protected]>[...]
Here is the summary with links:
- [net-next,01/39] can: kvaser_usb: kvaser_usb_set_bittiming(): fix redundant initialization warning for err
https://git.kernel.org/netdev/net-next/c/cce2d7d2abcc
- [net-next,02/39] can: kvaser_usb: kvaser_usb_set_{,data}bittiming(): remove empty lines in variable declaration
https://git.kernel.org/netdev/net-next/c/0bf582fc5168 - [net-next,03/39] can: rcar_canfd: rcar_canfd_probe: Add struct rcar_canfd_hw_info to driver data https://git.kernel.org/netdev/net-next/c/ce7c5382758b - [net-next,04/39] can: m_can: sort header inclusion alphabetically https://git.kernel.org/netdev/net-next/c/09451f244eab - [net-next,05/39] can: rcar_canfd: Add max_channels to struct rcar_canfd_hw_info https://git.kernel.org/netdev/net-next/c/34f9e9852b90 - [net-next,06/39] can: rcar_canfd: Add shared_global_irqs to struct rcar_canfd_hw_info https://git.kernel.org/netdev/net-next/c/841645cfc773 - [net-next,07/39] can: rcar_canfd: Add postdiv to struct rcar_canfd_hw_info https://git.kernel.org/netdev/net-next/c/a1dcfbdfd1d0 - [net-next,08/39] can: rcar_canfd: Add multi_channel_irqs to struct rcar_canfd_hw_info https://git.kernel.org/netdev/net-next/c/ea6ff7792203 - [net-next,09/39] can: ctucanfd: Drop obsolete dependency on COMPILE_TEST https://git.kernel.org/netdev/net-next/c/005c54278b3d - [net-next,10/39] can: etas_es58x: sort the includes by alphabetic order https://git.kernel.org/netdev/net-next/c/8fd9323ef721 - [net-next,11/39] can: flexcan: add auto stop mode for IMX93 to support wakeup https://git.kernel.org/netdev/net-next/c/8cb53b485f18 - [net-next,12/39] can: etas_es58x: add devlink support https://git.kernel.org/netdev/net-next/c/2c4a1efcf6ab - [net-next,13/39] dt-bindings: can: fsl,flexcan: add imx93 compatible https://git.kernel.org/netdev/net-next/c/a21cee59b416 - [net-next,14/39] can: etas_es58x: add devlink port support https://git.kernel.org/netdev/net-next/c/594a25e1ffc5 - [net-next,15/39] dt-bindings: can: renesas,rcar-canfd: Document RZ/Five SoC https://git.kernel.org/netdev/net-next/c/5237ff4e7d3d - [net-next,16/39] USB: core: export usb_cache_string() https://git.kernel.org/netdev/net-next/c/983055bf8397 - [net-next,17/39] can: c_can: use devm_platform_get_and_ioremap_resource() https://git.kernel.org/netdev/net-next/c/74d95352bdfc - [net-next,18/39] net: devlink: add DEVLINK_INFO_VERSION_GENERIC_FW_BOOTLOADER https://git.kernel.org/netdev/net-next/c/01d80532295c - [net-next,19/39] can: etas_es58x: export product information through devlink_ops::info_get() https://git.kernel.org/netdev/net-next/c/9f06631c3f1f - [net-next,20/39] can: etas_es58x: remove es58x_get_product_info() https://git.kernel.org/netdev/net-next/c/d8f26fd689dd - [net-next,21/39] Documentation: devlink: add devlink documentation for the etas_es58x driver https://git.kernel.org/netdev/net-next/c/9f63f96aac92 - [net-next,22/39] can: ucan: use strscpy() to instead of strncpy() https://git.kernel.org/netdev/net-next/c/7fdaf8966aae - [net-next,23/39] net: af_can: remove useless parameter 'err' in 'can_rx_register()' https://git.kernel.org/netdev/net-next/c/f793458bba54 - [net-next,24/39] can: ucan: remove unused ucan_priv::intf https://git.kernel.org/netdev/net-next/c/f54b101ddeae - [net-next,25/39] can: gs_usb: remove gs_can::iface https://git.kernel.org/netdev/net-next/c/56c56a309e79 - [net-next,26/39] can: m_can: Call the RAM init directly from m_can_chip_config https://git.kernel.org/netdev/net-next/c/eaacfeaca7ad - [net-next,27/39] can: raw: add support for SO_MARK https://git.kernel.org/netdev/net-next/c/0826e82b8a32 - [net-next,28/39] dt-bindings: can: renesas,rcar-canfd: Fix number of channels for R-Car V3U https://git.kernel.org/netdev/net-next/c/3abcc01c38bc - [net-next,29/39] can: m_can: Eliminate double read of TXFQS in tx_handler https://git.kernel.org/netdev/net-next/c/c1eaf8b9bd31 - [net-next,30/39] can: m_can: Avoid reading irqstatus twice https://git.kernel.org/netdev/net-next/c/577579379749 - [net-next,31/39] can: m_can: Read register PSR only on error https://git.kernel.org/netdev/net-next/c/fac52bf786e5 - [net-next,32/39] can: m_can: Count TXE FIFO getidx in the driver https://git.kernel.org/netdev/net-next/c/d4535b90a76a - [net-next,33/39] can: m_can: Count read getindex in the driver https://git.kernel.org/netdev/net-next/c/6355a3c983e6 - [net-next,34/39] can: m_can: Batch acknowledge transmit events https://git.kernel.org/netdev/net-next/c/e3bff5256a0f - [net-next,35/39] can: m_can: Batch acknowledge rx fifo https://git.kernel.org/netdev/net-next/c/e2f1c8cb0202 - [net-next,36/39] can: tcan4x5x: Remove invalid write in clear_interrupts https://git.kernel.org/netdev/net-next/c/40c9e4f676ab - [net-next,37/39] can: tcan4x5x: Fix use of register error status mask https://git.kernel.org/netdev/net-next/c/67727a17a6b3 - [net-next,38/39] can: tcan4x5x: Fix register range of first two blocks https://git.kernel.org/netdev/net-next/c/ef5778f70841 - [net-next,39/39] can: tcan4x5x: Specify separate read/write ranges https://git.kernel.org/netdev/net-next/c/39dbb21b6a29
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Marc Kleine-Budde
maintainerPATCH 2/39 can: kvaser_usb: kvaser_usb_set_{,data}bittiming(): remove empty lines in variable declaration
In reply to Marc Kleine-BuddeFix coding style by removing empty lines in variable declaration.
--- drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c +0 -2
@@ -536,7 +536,6 @@ static int kvaser_usb_set_bittiming(struct net_device *netdev)struct kvaser_usb *dev = priv->dev;const struct kvaser_usb_dev_ops *ops = dev->driver_info->ops;struct can_bittiming *bt = &priv->can.bittiming; -struct kvaser_usb_busparams busparams;int tseg1 = bt->prop_seg + bt->phase_seg1;int tseg2 = bt->phase_seg2;
@@ -581,7 +580,6 @@ static int kvaser_usb_set_data_bittiming(struct net_device *netdev)struct kvaser_usb *dev = priv->dev;const struct kvaser_usb_dev_ops *ops = dev->driver_info->ops;struct can_bittiming *dbt = &priv->can.data_bittiming; -struct kvaser_usb_busparams busparams;int tseg1 = dbt->prop_seg + dbt->phase_seg1;int tseg2 = dbt->phase_seg2;
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 3/39 can: rcar_canfd: rcar_canfd_probe: Add struct rcar_canfd_hw_info to driver data
In reply to Marc Kleine-BuddeFrom: Biju Das <[email protected]>
The CAN FD IP found on RZ/G2L SoC has some HW features different to that of R-Car. For example, it has multiple resets and multiple IRQs for global and channel interrupts. Also, it does not have ECC error flag registers and clk post divider present on R-Car. Similarly, R-Car V3U has 8 channels whereas other SoCs has only 2 channels.
This patch adds the struct rcar_canfd_hw_info to take care of the HW feature differences and driver data present on both IPs. It also replaces the driver data chip type with struct rcar_canfd_hw_info by moving chip type to it.
Whilst started using driver data instead of chip_id for detecting R-Car V3U SoCs.
--- drivers/net/can/rcar/rcar_canfd.c | 43 +++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 13 deletions(-)
drivers/net/can/rcar/rcar_canfd.c +30 -13
@@ -522,6 +522,10 @@ enum rcar_canfd_fcanclk {struct rcar_canfd_global ; +struct rcar_canfd_hw_info { +enum rcanfd_chip_id chip_id; +}; +/* Channel priv data */ struct rcar_canfd_channel {struct can_priv can;/* Must be the first member */
@@ -547,7 +551,7 @@ struct rcar_canfd_global {bool fdmode;/* CAN FD or Classical CAN only mode */ struct reset_control *rstc1;struct reset_control *rstc2; -enum rcanfd_chip_id chip_id; +const struct rcar_canfd_hw_info *info;u32 max_channels; };
@@ -590,10 +594,22 @@ static const struct can_bittiming_const rcar_canfd_bittiming_const = { .brp_inc = 1, }; +static const struct rcar_canfd_hw_info rcar_gen3_hw_info = { + .chip_id =RENESAS_RCAR_GEN3 , +}; + +static const struct rcar_canfd_hw_info rzg2l_hw_info = { + .chip_id =RENESAS_RZG2L , +}; + +static const struct rcar_canfd_hw_info r8a779a0_hw_info = { + .chip_id =RENESAS_R8A779A0 , +}; +/* Helper functions */ static inline bool is_v3u (struct rcar_canfd_global *gpriv) { -return gpriv->chip_id ==RENESAS_R8A779A0 ; +return gpriv->info == &r8a779a0_hw_info; } static inline u32 reg_v3u(struct rcar_canfd_global *gpriv,
@@ -1696,6 +1712,7 @@ static const struct ethtool_ops rcar_canfd_ethtool_ops = {static int rcar_canfd_channel_probe (struct rcar_canfd_global *gpriv,u32 ch,u32 fcan_freq) { +const struct rcar_canfd_hw_info *info = gpriv->info;struct platform_device *pdev = gpriv->pdev;struct rcar_canfd_channel *priv;struct net_device *ndev;
@@ -1718,7 +1735,7 @@ static int rcar_canfd_channel_probe(struct rcar_canfd_global *gpriv, u32 ch, priv->can.clock.freq = fcan_freq;dev_info (&pdev->dev,"can_clk rate is %u\n" , priv->can.clock.freq); -if (gpriv->chip_id ==RENESAS_RZG2L ) { +if (info->chip_id ==RENESAS_RZG2L ) {char *irq_name;int err_irq;int tx_irq;
@@ -1818,6 +1835,7 @@ static void rcar_canfd_channel_remove(struct rcar_canfd_global *gpriv, u32 ch)static int rcar_canfd_probe (struct platform_device *pdev) { +const struct rcar_canfd_hw_info *info;void __iomem *addr;u32 sts, ch, fcan_freq;struct rcar_canfd_global *gpriv;
@@ -1826,13 +1844,12 @@ static int rcar_canfd_probe(struct platform_device *pdev)int err, ch_irq, g_irq;int g_err_irq, g_recc_irq;bool fdmode = true;/* CAN FD only mode - default */ -enum rcanfd_chip_id chip_id;int max_channels;char name[9 ] ="channelX" ;int i; - chip_id = (uintptr_t )of_device_get_match_data (&pdev->dev); - max_channels = chip_id ==RENESAS_R8A779A0 ?8 :2 ; + info =of_device_get_match_data (&pdev->dev); + max_channels = info->chip_id ==RENESAS_R8A779A0 ?8 :2 ;if (of_property_read_bool (pdev->dev.of_node,"renesas,no-can-fd" )) fdmode = false;/* Classical CAN only mode */
@@ -1845,7 +1862,7 @@ static int rcar_canfd_probe(struct platform_device *pdev)of_node_put (of_child); } -if (chip_id !=RENESAS_RZG2L ) { +if (info->chip_id !=RENESAS_RZG2L ) { ch_irq =platform_get_irq_byname_optional (pdev,"ch_int" );if (ch_irq <0 ) {/* For backward compatibility get irq by index */
@@ -1879,7 +1896,7 @@ static int rcar_canfd_probe(struct platform_device *pdev) gpriv->pdev = pdev; gpriv->channels_mask = channels_mask; gpriv->fdmode = fdmode; - gpriv->chip_id = chip_id; + gpriv->info = info; gpriv->max_channels = max_channels; gpriv->rstc1 = devm_reset_control_get_optional_exclusive(&pdev->dev,
@@ -1917,7 +1934,7 @@ static int rcar_canfd_probe(struct platform_device *pdev) } fcan_freq =clk_get_rate (gpriv->can_clk); -if (gpriv->fcan ==RCANFD_CANFDCLK && gpriv->chip_id !=RENESAS_RZG2L ) +if (gpriv->fcan ==RCANFD_CANFDCLK && info->chip_id !=RENESAS_RZG2L )/* CANFD clock is further divided by (1/2) within the IP */ fcan_freq /=2 ;
@@ -1929,7 +1946,7 @@ static int rcar_canfd_probe(struct platform_device *pdev) gpriv->base = addr;/* Request IRQ that's common for both channels */ -if (gpriv->chip_id !=RENESAS_RZG2L ) { +if (info->chip_id !=RENESAS_RZG2L ) { err =devm_request_irq (&pdev->dev, ch_irq, rcar_canfd_channel_interrupt,0 ,"canfd.ch_int" , gpriv);
@@ -2082,9 +2099,9 @@ static SIMPLE_DEV_PM_OPS(rcar_canfd_pm_ops, rcar_canfd_suspend, rcar_canfd_resume);static const __maybe_unused struct of_device_id rcar_canfd_of_table[] = { - { .compatible ="renesas,rcar-gen3-canfd" , .data = (void *)RENESAS_RCAR_GEN3 }, - { .compatible ="renesas,rzg2l-canfd" , .data = (void *)RENESAS_RZG2L }, - { .compatible ="renesas,r8a779a0-canfd" , .data = (void *)RENESAS_R8A779A0 }, + { .compatible ="renesas,rcar-gen3-canfd" , .data = &rcar_gen3_hw_info }, + { .compatible ="renesas,rzg2l-canfd" , .data = &rzg2l_hw_info }, + { .compatible ="renesas,r8a779a0-canfd" , .data = &r8a779a0_hw_info }, { } };
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 4/39 can: m_can: sort header inclusion alphabetically
In reply to Marc Kleine-BuddeFrom: Vivek Yadav <[email protected]>
Sort header inclusion alphabetically.
--- drivers/net/can/m_can/m_can.c | 8 ++++---- drivers/net/can/m_can/m_can.h | 16 ++++++++-------- drivers/net/can/m_can/m_can_platform.c | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-)
drivers/net/can/m_can/m_can.c +4 -4
@@ -9,20 +9,20 @@*/ #include <linux/bitfield.h> +#include <linux/can/dev.h> #include <linux/ethtool.h> #include <linux/interrupt.h> #include <linux/io.h> +#include <linux/iopoll.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/netdevice.h> #include <linux/of.h> #include <linux/of_device.h> +#include <linux/phy/phy.h> +#include <linux/pinctrl/consumer.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> -#include <linux/iopoll.h> -#include <linux/can/dev.h> -#include <linux/pinctrl/consumer.h> -#include <linux/phy/phy.h> #include "m_can.h"
drivers/net/can/m_can/m_can.h +8 -8
@@ -7,27 +7,27 @@#define _CAN_M_CAN_H_#include <linux/can/core.h> +#include <linux/can/dev.h> #include <linux/can/rx-offload.h> +#include <linux/clk.h> #include <linux/completion.h> +#include <linux/delay.h> #include <linux/device.h> #include <linux/dma-mapping.h> #include <linux/freezer.h> -#include <linux/slab.h> -#include <linux/uaccess.h> -#include <linux/clk.h> -#include <linux/delay.h> #include <linux/interrupt.h> #include <linux/io.h> +#include <linux/iopoll.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/netdevice.h> #include <linux/of.h> #include <linux/of_device.h> -#include <linux/pm_runtime.h> -#include <linux/iopoll.h> -#include <linux/can/dev.h> -#include <linux/pinctrl/consumer.h> #include <linux/phy/phy.h> +#include <linux/pinctrl/consumer.h> +#include <linux/pm_runtime.h> +#include <linux/slab.h> +#include <linux/uaccess.h> /* m_can lec values */ enum m_can_lec_type {
drivers/net/can/m_can/m_can_platform.c +1 -1
@@ -5,8 +5,8 @@// // Copyright (C) 2018-19 Texas Instruments Incorporated - http://www.ti.com/ -#include <linux/platform_device.h> #include <linux/phy/phy.h> +#include <linux/platform_device.h> #include "m_can.h"
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 5/39 can: rcar_canfd: Add max_channels to struct rcar_canfd_hw_info
In reply to Marc Kleine-BuddeFrom: Biju Das <[email protected]>
R-Car V3U supports a maximum of 8 channels whereas rest of the SoCs support 2 channels.
Add max_channels variable to struct rcar_canfd_hw_info to handle this difference.
--- drivers/net/can/rcar/rcar_canfd.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
drivers/net/can/rcar/rcar_canfd.c +15 -15
@@ -524,6 +524,7 @@ struct rcar_canfd_global;struct rcar_canfd_hw_info {enum rcanfd_chip_id chip_id; +u8 max_channels; };/* Channel priv data */
@@ -552,7 +553,6 @@ struct rcar_canfd_global {struct reset_control *rstc1;struct reset_control *rstc2;const struct rcar_canfd_hw_info *info; -u32 max_channels; };/* CAN FD mode nominal rate constants */
@@ -596,14 +596,17 @@ static const struct can_bittiming_const rcar_canfd_bittiming_const = {static const struct rcar_canfd_hw_info rcar_gen3_hw_info = { .chip_id =RENESAS_RCAR_GEN3 , + .max_channels =2 , };static const struct rcar_canfd_hw_info rzg2l_hw_info = { .chip_id =RENESAS_RZG2L , + .max_channels =2 , };static const struct rcar_canfd_hw_info r8a779a0_hw_info = { .chip_id =RENESAS_R8A779A0 , + .max_channels =8 , };/* Helper functions */
@@ -737,7 +740,7 @@ static int rcar_canfd_reset_controller(struct rcar_canfd_global *gpriv)rcar_canfd_set_mode (gpriv);/* Transition all Channels to reset mode */ -for_each_set_bit (ch, &gpriv->channels_mask, gpriv->max_channels) { +for_each_set_bit (ch, &gpriv->channels_mask, gpriv->info->max_channels) {rcar_canfd_clear_bit (gpriv->base,RCANFD_CCTR (ch),RCANFD_CCTR_CSLPR );
@@ -778,7 +781,7 @@ static void rcar_canfd_configure_controller(struct rcar_canfd_global *gpriv)rcar_canfd_set_bit (gpriv->base,RCANFD_GCFG , cfg);/* Channel configuration settings */ -for_each_set_bit (ch, &gpriv->channels_mask, gpriv->max_channels) { +for_each_set_bit (ch, &gpriv->channels_mask, gpriv->info->max_channels) {rcar_canfd_set_bit (gpriv->base,RCANFD_CCTR (ch),RCANFD_CCTR_ERRD ); rcar_canfd_update_bit(gpriv->base, RCANFD_CCTR(ch),
@@ -1158,7 +1161,7 @@ static irqreturn_t rcar_canfd_global_err_interrupt(int irq, void *dev_id)struct rcar_canfd_global *gpriv = dev_id;u32 ch; -for_each_set_bit (ch, &gpriv->channels_mask, gpriv->max_channels) +for_each_set_bit (ch, &gpriv->channels_mask, gpriv->info->max_channels)rcar_canfd_handle_global_err (gpriv, ch);return IRQ_HANDLED ;
@@ -1190,7 +1193,7 @@ static irqreturn_t rcar_canfd_global_receive_fifo_interrupt(int irq, void *dev_istruct rcar_canfd_global *gpriv = dev_id;u32 ch; -for_each_set_bit (ch, &gpriv->channels_mask, gpriv->max_channels) +for_each_set_bit (ch, &gpriv->channels_mask, gpriv->info->max_channels)rcar_canfd_handle_global_receive (gpriv, ch);return IRQ_HANDLED ;
@@ -1204,7 +1207,7 @@ static irqreturn_t rcar_canfd_global_interrupt(int irq, void *dev_id)/* Global error interrupts still indicate a condition specific * to a channel. RxFIFO interrupt is a global interrupt. */ -for_each_set_bit (ch, &gpriv->channels_mask, gpriv->max_channels) { +for_each_set_bit (ch, &gpriv->channels_mask, gpriv->info->max_channels) {rcar_canfd_handle_global_err (gpriv, ch);rcar_canfd_handle_global_receive (gpriv, ch); }
@@ -1300,7 +1303,7 @@ static irqreturn_t rcar_canfd_channel_interrupt(int irq, void *dev_id)u32 ch;/* Common FIFO is a per channel resource */ -for_each_set_bit (ch, &gpriv->channels_mask, gpriv->max_channels) { +for_each_set_bit (ch, &gpriv->channels_mask, gpriv->info->max_channels) {rcar_canfd_handle_channel_err (gpriv, ch);rcar_canfd_handle_channel_tx (gpriv, ch); }
@@ -1844,17 +1847,15 @@ static int rcar_canfd_probe(struct platform_device *pdev)int err, ch_irq, g_irq;int g_err_irq, g_recc_irq;bool fdmode = true;/* CAN FD only mode - default */ -int max_channels;char name[9 ] ="channelX" ;int i; info =of_device_get_match_data (&pdev->dev); - max_channels = info->chip_id ==RENESAS_R8A779A0 ?8 :2 ;if (of_property_read_bool (pdev->dev.of_node,"renesas,no-can-fd" )) fdmode = false;/* Classical CAN only mode */ -for (i =0 ; i < max_channels; ++i) { +for (i =0 ; i < info->max_channels; ++i) { name[7 ] ='0' + i; of_child =of_get_child_by_name (pdev->dev.of_node, name);if (of_child &&of_device_is_available (of_child))
@@ -1897,7 +1898,6 @@ static int rcar_canfd_probe(struct platform_device *pdev) gpriv->channels_mask = channels_mask; gpriv->fdmode = fdmode; gpriv->info = info; - gpriv->max_channels = max_channels; gpriv->rstc1 =devm_reset_control_get_optional_exclusive (&pdev->dev,"rstp_n" );
@@ -2012,7 +2012,7 @@ static int rcar_canfd_probe(struct platform_device *pdev)rcar_canfd_configure_controller (gpriv);/* Configure per channel attributes */ -for_each_set_bit (ch, &gpriv->channels_mask, max_channels) { +for_each_set_bit (ch, &gpriv->channels_mask, info->max_channels) {/* Configure Channel's Rx fifo */ rcar_canfd_configure_rx (gpriv, ch);
@@ -2038,7 +2038,7 @@ static int rcar_canfd_probe(struct platform_device *pdev) goto fail_mode; } -for_each_set_bit (ch, &gpriv->channels_mask, max_channels) { +for_each_set_bit (ch, &gpriv->channels_mask, info->max_channels) { err =rcar_canfd_channel_probe (gpriv, ch, fcan_freq);if (err) goto fail_channel;
@@ -2050,7 +2050,7 @@ static int rcar_canfd_probe(struct platform_device *pdev)return 0 ; fail_channel: -for_each_set_bit (ch, &gpriv->channels_mask, max_channels) +for_each_set_bit (ch, &gpriv->channels_mask, info->max_channels)rcar_canfd_channel_remove (gpriv, ch); fail_mode:rcar_canfd_disable_global_interrupts (gpriv);
@@ -2071,7 +2071,7 @@ static int rcar_canfd_remove(struct platform_device *pdev)rcar_canfd_reset_controller (gpriv);rcar_canfd_disable_global_interrupts (gpriv); -for_each_set_bit (ch, &gpriv->channels_mask, gpriv->max_channels) { +for_each_set_bit (ch, &gpriv->channels_mask, gpriv->info->max_channels) {rcar_canfd_disable_channel_interrupts (gpriv->ch[ch]);rcar_canfd_channel_remove (gpriv, ch); }
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 6/39 can: rcar_canfd: Add shared_global_irqs to struct rcar_canfd_hw_info
In reply to Marc Kleine-BuddeFrom: Biju Das <[email protected]>
RZ/G2L has separate IRQ lines for receive FIFO and global error interrupt whereas R-Car has shared IRQ line.
Add shared_global_irqs to struct rcar_canfd_hw_info to select the driver to choose between shared and separate irq registration for global interrupts.
--- drivers/net/can/rcar/rcar_canfd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/can/rcar/rcar_canfd.c +6 -2
@@ -525,6 +525,8 @@ struct rcar_canfd_global;struct rcar_canfd_hw_info {enum rcanfd_chip_id chip_id;u8 max_channels; +/* hardware features */ +unsigned shared_global_irqs:1 ;/* Has shared global irqs */ };/* Channel priv data */
@@ -597,6 +599,7 @@ static const struct can_bittiming_const rcar_canfd_bittiming_const = {static const struct rcar_canfd_hw_info rcar_gen3_hw_info = { .chip_id =RENESAS_RCAR_GEN3 , .max_channels =2 , + .shared_global_irqs =1 , };static const struct rcar_canfd_hw_info rzg2l_hw_info = {
@@ -607,6 +610,7 @@ static const struct rcar_canfd_hw_info rzg2l_hw_info = {static const struct rcar_canfd_hw_info r8a779a0_hw_info = { .chip_id =RENESAS_R8A779A0 , .max_channels =8 , + .shared_global_irqs =1 , };/* Helper functions */
@@ -1863,7 +1867,7 @@ static int rcar_canfd_probe(struct platform_device *pdev)of_node_put (of_child); } -if (info->chip_id !=RENESAS_RZG2L ) { +if (info->shared_global_irqs) { ch_irq =platform_get_irq_byname_optional (pdev,"ch_int" );if (ch_irq <0 ) {/* For backward compatibility get irq by index */
@@ -1946,7 +1950,7 @@ static int rcar_canfd_probe(struct platform_device *pdev) gpriv->base = addr;/* Request IRQ that's common for both channels */ -if (info->chip_id !=RENESAS_RZG2L ) { +if (info->shared_global_irqs) { err =devm_request_irq (&pdev->dev, ch_irq, rcar_canfd_channel_interrupt,0 ,"canfd.ch_int" , gpriv);
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 7/39 can: rcar_canfd: Add postdiv to struct rcar_canfd_hw_info
In reply to Marc Kleine-BuddeFrom: Biju Das <[email protected]>
R-Car has a clock divider for CAN FD clock within the IP, whereas it is not available on RZ/G2L.
Add postdiv variable to struct rcar_canfd_hw_info to take care of this difference.
--- drivers/net/can/rcar/rcar_canfd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/can/rcar/rcar_canfd.c +6 -2
@@ -525,6 +525,7 @@ struct rcar_canfd_global;struct rcar_canfd_hw_info {enum rcanfd_chip_id chip_id;u8 max_channels; +u8 postdiv;/* hardware features */ unsigned shared_global_irqs:1 ;/* Has shared global irqs */ };
@@ -599,17 +600,20 @@ static const struct can_bittiming_const rcar_canfd_bittiming_const = {static const struct rcar_canfd_hw_info rcar_gen3_hw_info = { .chip_id =RENESAS_RCAR_GEN3 , .max_channels =2 , + .postdiv =2 , .shared_global_irqs =1 , };static const struct rcar_canfd_hw_info rzg2l_hw_info = { .chip_id =RENESAS_RZG2L , + .postdiv =1 , .max_channels =2 , };static const struct rcar_canfd_hw_info r8a779a0_hw_info = { .chip_id =RENESAS_R8A779A0 , .max_channels =8 , + .postdiv =2 , .shared_global_irqs =1 , };
@@ -1938,9 +1942,9 @@ static int rcar_canfd_probe(struct platform_device *pdev) } fcan_freq =clk_get_rate (gpriv->can_clk); -if (gpriv->fcan ==RCANFD_CANFDCLK && info->chip_id !=RENESAS_RZG2L ) +if (gpriv->fcan ==RCANFD_CANFDCLK )/* CANFD clock is further divided by (1/2) within the IP */ - fcan_freq /=2 ; + fcan_freq /= info->postdiv; addr =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (addr)) {
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 8/39 can: rcar_canfd: Add multi_channel_irqs to struct rcar_canfd_hw_info
In reply to Marc Kleine-BuddeFrom: Biju Das <[email protected]>
RZ/G2L has separate IRQ lines for tx and error interrupt for each channel whereas R-Car has a combined IRQ line for all the channel specific tx and error interrupts.
Add multi_channel_irqs to struct rcar_canfd_hw_info to select the driver to choose between combined and separate irq registration for channel interrupts. This patch also removes enum rcanfd_chip_id and chip_id from both struct rcar_canfd_hw_info, as it is unused.
--- drivers/net/can/rcar/rcar_canfd.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
drivers/net/can/rcar/rcar_canfd.c +4 -12
@@ -41,12 +41,6 @@#define RCANFD_DRV_NAME "rcar_canfd" -enum rcanfd_chip_id { -RENESAS_RCAR_GEN3 =0 , -RENESAS_RZG2L , -RENESAS_R8A779A0 , -}; -/* Global register bits */ /* RSCFDnCFDGRMCFG */
@@ -523,11 +517,11 @@ enum rcar_canfd_fcanclk {struct rcar_canfd_global ;struct rcar_canfd_hw_info { -enum rcanfd_chip_id chip_id;u8 max_channels;u8 postdiv;/* hardware features */ unsigned shared_global_irqs:1 ;/* Has shared global irqs */ +unsigned multi_channel_irqs:1 ;/* Has multiple channel irqs */ };/* Channel priv data */
@@ -598,20 +592,18 @@ static const struct can_bittiming_const rcar_canfd_bittiming_const = { };static const struct rcar_canfd_hw_info rcar_gen3_hw_info = { - .chip_id =RENESAS_RCAR_GEN3 , .max_channels =2 , .postdiv =2 , .shared_global_irqs =1 , };static const struct rcar_canfd_hw_info rzg2l_hw_info = { - .chip_id =RENESAS_RZG2L , - .postdiv =1 , .max_channels =2 , + .postdiv =1 , + .multi_channel_irqs =1 , };static const struct rcar_canfd_hw_info r8a779a0_hw_info = { - .chip_id =RENESAS_R8A779A0 , .max_channels =8 , .postdiv =2 , .shared_global_irqs =1 ,
@@ -1746,7 +1738,7 @@ static int rcar_canfd_channel_probe(struct rcar_canfd_global *gpriv, u32 ch, priv->can.clock.freq = fcan_freq;dev_info (&pdev->dev,"can_clk rate is %u\n" , priv->can.clock.freq); -if (info->chip_id ==RENESAS_RZG2L ) { +if (info->multi_channel_irqs) {char *irq_name;int err_irq;int tx_irq;
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 9/39 can: ctucanfd: Drop obsolete dependency on COMPILE_TEST
In reply to Marc Kleine-BuddeFrom: Jean Delvare <[email protected]>
Since commit 0166dc11be91 ("of: make CONFIG_OF user selectable"), it is possible to test-build any driver which depends on OF on any architecture by explicitly selecting OF. Therefore depending on COMPILE_TEST as an alternative is no longer needed.
It is actually better to always build such drivers with OF enabled, so that the test builds are closer to how each driver will actually be built on its intended target. Building them without OF may not test much as the compiler will optimize out potentially large parts of the code. In the worst case, this could even pop false positive warnings. Dropping COMPILE_TEST here improves the quality of our testing and avoids wasting time on non-existent issues.
--- drivers/net/can/ctucanfd/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/ctucanfd/Kconfig +1 -1
@@ -23,7 +23,7 @@ config CAN_CTUCANFD_PCI config CAN_CTUCANFD_PLATFORM tristate "CTU CAN-FD IP core platform (FPGA, SoC) driver" - depends on HAS_IOMEM && (OF || COMPILE_TEST) + depends on HAS_IOMEM && OF select CAN_CTUCANFD help The core has been tested together with OpenCores SJA1000
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 10/39 can: etas_es58x: sort the includes by alphabetic order
In reply to Marc Kleine-BuddeFrom: Vincent Mailhol <[email protected]>
Follow the best practices, reorder the includes.
While doing so, bump up copyright year of each modified files.
--- drivers/net/can/usb/etas_es58x/es581_4.c | 4 ++-- drivers/net/can/usb/etas_es58x/es58x_core.c | 6 +++--- drivers/net/can/usb/etas_es58x/es58x_core.h | 8 ++++---- drivers/net/can/usb/etas_es58x/es58x_fd.c | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-)
drivers/net/can/usb/etas_es58x/es581_4.c +2 -2
@@ -6,12 +6,12 @@* * Copyright (c) 2019 Robert Bosch Engineering and Business Solutions. All rights reserved. * Copyright (c) 2020 ETAS K.K.. All rights reserved. -* Copyright (c) 2020, 2021 Vincent Mailhol <[email protected]> +* Copyright (c) 2020-2022 Vincent Mailhol <[email protected]> */ +#include <asm/unaligned.h> #include <linux/kernel.h> #include <linux/units.h> -#include <asm/unaligned.h> #include "es58x_core.h" #include "es581_4.h"
drivers/net/can/usb/etas_es58x/es58x_core.c +3 -3
@@ -7,15 +7,15 @@* * Copyright (c) 2019 Robert Bosch Engineering and Business Solutions. All rights reserved. * Copyright (c) 2020 ETAS K.K.. All rights reserved. -* Copyright (c) 2020, 2021 Vincent Mailhol <[email protected]> +* Copyright (c) 2020-2022 Vincent Mailhol <[email protected]> */ +#include <asm/unaligned.h> +#include <linux/crc16.h> #include <linux/ethtool.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/usb.h> -#include <linux/crc16.h> -#include <asm/unaligned.h> #include "es58x_core.h"
drivers/net/can/usb/etas_es58x/es58x_core.h +4 -4
@@ -6,17 +6,17 @@* * Copyright (c) 2019 Robert Bosch Engineering and Business Solutions. All rights reserved. * Copyright (c) 2020 ETAS K.K.. All rights reserved. -* Copyright (c) 2020, 2021 Vincent Mailhol <[email protected]> +* Copyright (c) 2020-2022 Vincent Mailhol <[email protected]> */ #ifndef __ES58X_COMMON_H__#define __ES58X_COMMON_H__ -#include <linux/types.h> -#include <linux/usb.h> -#include <linux/netdevice.h> #include <linux/can.h> #include <linux/can/dev.h> +#include <linux/netdevice.h> +#include <linux/types.h> +#include <linux/usb.h> #include "es581_4.h" #include "es58x_fd.h"
drivers/net/can/usb/etas_es58x/es58x_fd.c +2 -2
@@ -8,12 +8,12 @@* * Copyright (c) 2019 Robert Bosch Engineering and Business Solutions. All rights reserved. * Copyright (c) 2020 ETAS K.K.. All rights reserved. -* Copyright (c) 2020, 2021 Vincent Mailhol <[email protected]> +* Copyright (c) 2020-2022 Vincent Mailhol <[email protected]> */ +#include <asm/unaligned.h> #include <linux/kernel.h> #include <linux/units.h> -#include <asm/unaligned.h> #include "es58x_core.h" #include "es58x_fd.h"
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 11/39 can: flexcan: add auto stop mode for IMX93 to support wakeup
In reply to Marc Kleine-BuddeFrom: Haibo Chen <[email protected]>
IMX93 do not contain a GPR to config the stop mode, it will set the flexcan into stop mode automatically once the ARM core go into low power mode (WFI instruct) and gate off the flexcan related clock automatically. But to let these logic work as expect, before ARM core go into low power mode, need to make sure the flexcan related clock keep on.
To support stop mode and wakeup feature on imx93, this patch add a new fsl_imx93_devtype_data to separate from imx8mp.
--- drivers/net/can/flexcan/flexcan-core.c | 37 +++++++++++++++++++++++--- drivers/net/can/flexcan/flexcan.h | 2 ++ 2 files changed, 36 insertions(+), 3 deletions(-)
drivers/net/can/flexcan/flexcan-core.c +34 -3
@@ -345,6 +345,15 @@ static struct flexcan_devtype_data fsl_imx8mp_devtype_data = { FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR, }; +static struct flexcan_devtype_data fsl_imx93_devtype_data = { + .quirks =FLEXCAN_QUIRK_DISABLE_RXFG |FLEXCAN_QUIRK_ENABLE_EACEN_RRS | +FLEXCAN_QUIRK_DISABLE_MECR |FLEXCAN_QUIRK_USE_RX_MAILBOX | +FLEXCAN_QUIRK_BROKEN_PERR_STATE |FLEXCAN_QUIRK_AUTO_STOP_MODE | +FLEXCAN_QUIRK_SUPPORT_FD |FLEXCAN_QUIRK_SUPPORT_ECC | +FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX | +FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR , +}; +static const struct flexcan_devtype_data fsl_vf610_devtype_data = { .quirks =FLEXCAN_QUIRK_DISABLE_RXFG |FLEXCAN_QUIRK_ENABLE_EACEN_RRS | FLEXCAN_QUIRK_DISABLE_MECR | FLEXCAN_QUIRK_USE_RX_MAILBOX |
@@ -532,9 +541,14 @@ static inline int flexcan_enter_stop_mode(struct flexcan_priv *priv) ret =flexcan_stop_mode_enable_scfw (priv, true);if (ret <0 )return ret; - }else { + }else if (priv->devtype_data.quirks &FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR ) {regmap_update_bits (priv->stm.gpr, priv->stm.req_gpr,1 << priv->stm.req_bit,1 << priv->stm.req_bit); + }else if (priv->devtype_data.quirks &FLEXCAN_QUIRK_AUTO_STOP_MODE ) { +/* For the auto stop mode, software do nothing, hardware will cover +* all the operation automatically after system go into low power mode. +*/ +return 0 ; }return flexcan_low_power_enter_ack (priv);
@@ -551,7 +565,7 @@ static inline int flexcan_exit_stop_mode(struct flexcan_priv *priv) ret =flexcan_stop_mode_enable_scfw (priv, false);if (ret <0 )return ret; - }else { + }else if (priv->devtype_data.quirks &FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR ) {regmap_update_bits (priv->stm.gpr, priv->stm.req_gpr,1 << priv->stm.req_bit,0 ); }
@@ -560,6 +574,12 @@ static inline int flexcan_exit_stop_mode(struct flexcan_priv *priv) reg_mcr &= ~FLEXCAN_MCR_SLF_WAK ; priv->write (reg_mcr, ®s->mcr); +/* For the auto stop mode, hardware will exist stop mode +* automatically after system go out of low power mode. +*/ +if (priv->devtype_data.quirks &FLEXCAN_QUIRK_AUTO_STOP_MODE ) +return 0 ; +return flexcan_low_power_exit_ack (priv); }
@@ -1974,6 +1994,8 @@ static int flexcan_setup_stop_mode(struct platform_device *pdev) ret =flexcan_setup_stop_mode_scfw (pdev); else if (priv->devtype_data.quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR) ret =flexcan_setup_stop_mode_gpr (pdev); + else if (priv->devtype_data.quirks & FLEXCAN_QUIRK_AUTO_STOP_MODE) + ret =0 ; else/* return 0 directly if doesn't support stop mode feature */ return 0;
@@ -1992,6 +2014,7 @@ static int flexcan_setup_stop_mode(struct platform_device *pdev)static const struct of_device_id flexcan_of_match[] = { { .compatible ="fsl,imx8qm-flexcan" , .data = &fsl_imx8qm_devtype_data, }, { .compatible ="fsl,imx8mp-flexcan" , .data = &fsl_imx8mp_devtype_data, }, + { .compatible ="fsl,imx93-flexcan" , .data = &fsl_imx93_devtype_data, }, { .compatible ="fsl,imx6q-flexcan" , .data = &fsl_imx6q_devtype_data, }, { .compatible ="fsl,imx28-flexcan" , .data = &fsl_imx28_devtype_data, }, { .compatible ="fsl,imx53-flexcan" , .data = &fsl_imx25_devtype_data, },
@@ -2299,8 +2322,16 @@ static int __maybe_unused flexcan_noirq_suspend(struct device *device)if (netif_running (dev)) {int err; -if (device_may_wakeup (device)) +if (device_may_wakeup (device)) {flexcan_enable_wakeup_irq (priv, true); +/* For auto stop mode, need to keep the clock on before +* system go into low power mode. After system go into +* low power mode, hardware will config the flexcan into +* stop mode, and gate off the clock automatically. +*/ +if (priv->devtype_data.quirks &FLEXCAN_QUIRK_AUTO_STOP_MODE ) +return 0 ; + } err =pm_runtime_force_suspend (device);if (err)
drivers/net/can/flexcan/flexcan.h +2 -0
@@ -68,6 +68,8 @@#define FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR BIT(15)/* Device supports RX via FIFO */ #define FLEXCAN_QUIRK_SUPPORT_RX_FIFO BIT(16) +/* auto enter stop mode to support wakeup */ +#define FLEXCAN_QUIRK_AUTO_STOP_MODE BIT(17)struct flexcan_devtype_data {u32 quirks;/* quirks needed for different IP cores */
Signature · 1 line
2.35.1
RE: [PATCH net-next 11/39] can: flexcan: add auto stop mode for IMX93 to support wakeup
Quoted 31 lines
-----Original Message-----
From: Marc Kleine-Budde <[email protected]>
Sent: 2022年12月12日 19:30
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Bough Chen <[email protected]>; Marc Kleine-Budde <[email protected]>
Subject: [PATCH net-next 11/39] can: flexcan: add auto stop mode for IMX93 to support wakeupFrom: Haibo Chen <[email protected]>
IMX93 do not contain a GPR to config the stop mode, it will set the flexcan into stop mode automatically once the ARM core go into low power mode (WFI instruct) and gate off the flexcan related clock automatically. But to let these logic work as expect, before ARM core go into low power mode, need to make sure the flexcan related clock keep on.
To support stop mode and wakeup feature on imx93, this patch add a new
fsl_imx93_devtype_datato separate from imx8mp.Signed-off-by Haibo Chen <[email protected]>Link:
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kern
el.org%2Fall%2F1669116752-4260-1-git-send-email-haibo.chen%40nxp.com&a mp;data=05%7C01%7Chaibo.chen%40nxp.com%7C57db640faf1a4fe6ac9e08da dc34556c%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C638064414 581423735%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV 2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata= yc1AspfoVq%2BHKokRFxf06vcaqqP%2FtZUnpMnTaXL97y8%3D&reserved= 0
Quoted 1 line
Signed-off-by Marc Kleine-Budde <[email protected]>
Hi Marc,
Thanks for sending this patch.
But this patch has one runtime PM unbalance issue, I will fix this issue and send again these days.
Best Regards
Haibo Chen
Quoted 135 lines
--- drivers/net/can/flexcan/flexcan-core.c | 37 +++++++++++++++++++++++--- drivers/net/can/flexcan/flexcan.h | 2 ++ 2 files changed, 36 insertions(+), 3 deletions(-)drivers/net/can/flexcan/flexcan-core.c +2
-0@@ -345,6 +345,15 @@ static struct flexcan_devtype_data fsl_imx8mp_devtype_data = { FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR, }; +static struct flexcan_devtype_data fsl_imx93_devtype_data = { + .quirks = FLEXCAN_QUIRK_DISABLE_RXFG |
FLEXCAN_QUIRK_ENABLE_EACEN_RRS|drivers/net/can/flexcan/flexcan-core.c +1
-0+ FLEXCAN_QUIRK_DISABLE_MECR |
FLEXCAN_QUIRK_USE_RX_MAILBOX|drivers/net/can/flexcan/flexcan-core.c +1
-0+ FLEXCAN_QUIRK_BROKEN_PERR_STATE |
FLEXCAN_QUIRK_AUTO_STOP_MODE|drivers/net/can/flexcan/flexcan-core.c +5
-0+ FLEXCAN_QUIRK_SUPPORT_FD | FLEXCAN_QUIRK_SUPPORT_ECC | + FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX | + FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR, +}; +static const struct flexcan_devtype_data fsl_vf610_devtype_data = { .quirks = FLEXCAN_QUIRK_DISABLE_RXFG |
FLEXCAN_QUIRK_ENABLE_EACEN_RRS|
FLEXCAN_QUIRK_DISABLE_MECR|FLEXCAN_QUIRK_USE_RX_MAILBOX| @@ -532,9 +541,14 @@ static inline intflexcan_enter_stop_mode(struct flexcan_priv *priv)drivers/net/can/flexcan/flexcan-core.c +3
-1ret =flexcan_stop_mode_enable_scfw (priv, true);if (ret <0 )return ret; - }else { + }else if (priv->devtype_data.quirks & +FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR ) {regmap_update_bits (priv->stm.gpr, priv->stm.req_gpr,1 << priv->stm.req_bit,1 << priv->stm.req_bit); + }else if (priv->devtype_data.quirks &FLEXCAN_QUIRK_AUTO_STOP_MODE ){
drivers/net/can/flexcan/flexcan-core.c +2
-0+/* For the auto stop mode, software do nothing, hardware will cover +* all the operation automatically after system go into low power mode.
drivers/net/can/flexcan/flexcan-core.c +12
-1+*/ +return 0 ; }return flexcan_low_power_enter_ack (priv);@@ -551,7 +565,7 @@ static inline int flexcan_exit_stop_mode(struct flexcan_priv *priv) ret =flexcan_stop_mode_enable_scfw (priv, false);if (ret <0 )return ret; - }else { + }else if (priv->devtype_data.quirks & +FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR ) {regmap_update_bits (priv->stm.gpr, priv->stm.req_gpr,1 << priv->stm.req_bit,0 ); }@@ -560,6 +574,12 @@ static inline int flexcan_exit_stop_mode(struct flexcan_priv *priv) reg_mcr &= ~FLEXCAN_MCR_SLF_WAK; priv->write (reg_mcr, ®s->mcr); +/* For the auto stop mode, hardware will exist stop mode +* automatically after system go out of low power mode. +*/ +if (priv->devtype_data.quirks &FLEXCAN_QUIRK_AUTO_STOP_MODE ) +return 0 ; +return flexcan_low_power_exit_ack (priv); }@@ -1974,6 +1994,8 @@ static int flexcan_setup_stop_mode(struct platform_device *pdev) ret =flexcan_setup_stop_mode_scfw (pdev); else if (priv->devtype_data.quirks &FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR ) ret =flexcan_setup_stop_mode_gpr (pdev); + else if (priv->devtype_data.quirks & FLEXCAN_QUIRK_AUTO_STOP_MODE) + ret =0 ; elsedrivers/net/can/flexcan/flexcan-core.c +0
-0/* return 0 directly if doesn't support stop mode feature */ return 0 ;@@ -1992,6 +2014,7 @@ static int flexcan_setup_stop_mode(struct
platform_device*pdev) static const structof_device_idflexcan_of_match[] = {
{ .compatible = "fsl,imx8qm-flexcan", .data =&fsl_imx8qm_devtype_data, },
{ .compatible = "fsl,imx8mp-flexcan", .data =&fsl_imx8mp_devtype_data, },drivers/net/can/flexcan/flexcan-core.c +11
-1+ { .compatible = "fsl,imx93-flexcan", .data = &fsl_imx93_devtype_data, +}, { .compatible = "fsl,imx6q-flexcan", .data = &fsl_imx6q_devtype_data, }, { .compatible = "fsl,imx28-flexcan", .data = &fsl_imx28_devtype_data, }, { .compatible = "fsl,imx53-flexcan", .data = &fsl_imx25_devtype_data, },@@ -2299,8 +2322,16 @@ static int __maybe_unused flexcan_noirq_suspend(struct device *device) if (netif_running(dev)) {int err; -if (device_may_wakeup (device)) +if (device_may_wakeup (device)) {flexcan_enable_wakeup_irq (priv, true); +/* For auto stop mode, need to keep the clock on before +* system go into low power mode. After system go into +* low power mode, hardware will config the flexcan into +* stop mode, and gate off the clock automatically. +*/ +if (priv->devtype_data.quirks &FLEXCAN_QUIRK_AUTO_STOP_MODE ) +return 0 ; + }drivers/net/can/flexcan/flexcan-core.c +0
-0err =pm_runtime_force_suspend (device);if (err)drivers/net/can/flexcan/flexcan.h +2
-1@@ -68,6 +68,8 @@#define FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR BIT(15)/* Device supports RX via FIFO */ #define FLEXCAN_QUIRK_SUPPORT_RX_FIFO BIT(16) +/* auto enter stop mode to support wakeup */ #define +FLEXCAN_QUIRK_AUTO_STOP_MODE BIT(17)struct flexcan_devtype_data {u32 quirks;/* quirks needed for different IP cores */ --2.35.1
Marc Kleine-Budde
maintainerRe: RE: [PATCH net-next 11/39] can: flexcan: add auto stop mode for IMX93 to support wakeup
Quoted 33 lines · Bough Chen
Quoted 31 lines
-----Original Message-----
From: Marc Kleine-Budde <[email protected]>
Sent: 2022年12月12日 19:30
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Bough Chen <[email protected]>; Marc Kleine-Budde <[email protected]>
Subject: [PATCH net-next 11/39] can: flexcan: add auto stop mode for IMX93 to support wakeupFrom: Haibo Chen <[email protected]>
IMX93 do not contain a GPR to config the stop mode, it will set the flexcan into stop mode automatically once the ARM core go into low power mode (WFI instruct) and gate off the flexcan related clock automatically. But to let these logic work as expect, before ARM core go into low power mode, need to make sure the flexcan related clock keep on.
To support stop mode and wakeup feature on imx93, this patch add a new
fsl_imx93_devtype_datato separate from imx8mp.Signed-off-by Haibo Chen <[email protected]>Link:
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kern
el.org%2Fall%2F1669116752-4260-1-git-send-email-haibo.chen%40nxp.com&a mp;data=05%7C01%7Chaibo.chen%40nxp.com%7C57db640faf1a4fe6ac9e08da dc34556c%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C638064414 581423735%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV 2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata= yc1AspfoVq%2BHKokRFxf06vcaqqP%2FtZUnpMnTaXL97y8%3D&reserved= 0Quoted 1 line
Signed-off-by Marc Kleine-Budde <[email protected]>
Quoted 4 lines
Hi Marc,
Thanks for sending this patch.
But this patch has one runtime PM unbalance issue, I will fix this issue and send again these days.
It's in net-next now, please send an incremental patch.
regards,
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Marc Kleine-Budde
maintainerPATCH 12/39 can: etas_es58x: add devlink support
In reply to Marc Kleine-BuddeFrom: Vincent Mailhol <[email protected]>
Add basic support for devlink at the device level. The callbacks of struct devlink_ops will be implemented next.
--- drivers/net/can/usb/Kconfig | 1 + drivers/net/can/usb/etas_es58x/Makefile | 2 +- drivers/net/can/usb/etas_es58x/es58x_core.c | 13 ++++++++++--- drivers/net/can/usb/etas_es58x/es58x_core.h | 6 ++++++ drivers/net/can/usb/etas_es58x/es58x_devlink.c | 13 +++++++++++++ 5 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 drivers/net/can/usb/etas_es58x/es58x_devlink.c
drivers/net/can/usb/Kconfig +1 -0
@@ -30,6 +30,7 @@ config CAN_ESD_USB config CAN_ETAS_ES58X tristate "ETAS ES58X CAN/USB interfaces" select CRC16 + select NET_DEVLINK help This driver supports the ES581.4, ES582.1 and ES584.1 interfaces from ETAS GmbH (https://www.etas.com/en/products/es58x.php).
drivers/net/can/usb/etas_es58x/Makefile +1 -1
@@ -1,3 +1,3 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_CAN_ETAS_ES58X) += etas_es58x.o -etas_es58x-y = es58x_core.o es581_4.o es58x_fd.o +etas_es58x-y = es58x_core.o es58x_devlink.o es581_4.o es58x_fd.o
drivers/net/can/usb/etas_es58x/es58x_core.c +10 -3
@@ -16,6 +16,7 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/usb.h> +#include <net/devlink.h> #include "es58x_core.h"
@@ -2177,6 +2178,7 @@ static struct es58x_device *es58x_init_es58x_dev(struct usb_interface *intf, {struct device *dev = &intf->dev;struct es58x_device *es58x_dev; +struct devlink *devlink;const struct es58x_parameters *param;const struct es58x_operators *ops;struct usb_device *udev =interface_to_usbdev (intf);
@@ -2199,11 +2201,12 @@ static struct es58x_device *es58x_init_es58x_dev(struct usb_interface *intf, ops = &es581_4_ops; } - es58x_dev =devm_kzalloc (dev,es58x_sizeof_es58x_device (param), -GFP_KERNEL ); -if (!es58x_dev) + devlink =devlink_alloc (&es58x_dl_ops,es58x_sizeof_es58x_device (param), + dev); +if (!devlink)return ERR_PTR (-ENOMEM ); + es58x_dev =devlink_priv (devlink); es58x_dev->param = param; es58x_dev->ops = ops; es58x_dev->dev = dev;
@@ -2250,6 +2253,8 @@ static int es58x_probe(struct usb_interface *intf,if (ret)return ret; +devlink_register (priv_to_devlink (es58x_dev)); +for (ch_idx =0 ; ch_idx < es58x_dev->num_can_ch; ch_idx++) { ret =es58x_init_netdev (es58x_dev, ch_idx);if (ret) {
@@ -2275,8 +2280,10 @@ static void es58x_disconnect(struct usb_interface *intf)dev_info (&intf->dev,"Disconnecting %s %s\n" , es58x_dev->udev->manufacturer, es58x_dev->udev->product); +devlink_unregister (priv_to_devlink (es58x_dev));es58x_free_netdevs (es58x_dev);es58x_free_urbs (es58x_dev); +devlink_free (priv_to_devlink (es58x_dev));usb_set_intfdata (intf,NULL ); }
drivers/net/can/usb/etas_es58x/es58x_core.h +6 -0
@@ -674,6 +674,7 @@ static inline enum es58x_flag es58x_get_flags(const struct sk_buff *skb)return es58x_flags; } +/* es58x_core.c. */ int es58x_can_get_echo_skb (struct net_device *netdev,u32 packet_idx,u64 *tstamps,unsigned int pkts); int es58x_tx_ack_msg(struct net_device *netdev, u16 tx_free_entries,
@@ -691,9 +692,14 @@ int es58x_rx_cmd_ret_u32(struct net_device *netdev,int es58x_send_msg (struct es58x_device *es58x_dev,u8 cmd_type,u8 cmd_id,const void *msg,u16 cmd_len,int channel_idx); +/* es58x_devlink.c. */ +extern const struct devlink_ops es58x_dl_ops; + +/* es581_4.c. */ extern const struct es58x_parameters es581_4_param;extern const struct es58x_operators es581_4_ops; +/* es58x_fd.c. */ extern const struct es58x_parameters es58x_fd_param;extern const struct es58x_operators es58x_fd_ops;
drivers/net/can/usb/etas_es58x/es58x_devlink.c new file +13 -0
@@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* Driver for ETAS GmbH ES58X USB CAN(-FD) Bus Interfaces. +* +* File es58x_devlink.c: report the product information using devlink. +* +* Copyright (c) 2022 Vincent Mailhol <[email protected]> +*/ + +#include <net/devlink.h> + +const struct devlink_ops es58x_dl_ops = { +};
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 13/39 dt-bindings: can: fsl,flexcan: add imx93 compatible
In reply to Marc Kleine-BuddeFrom: Haibo Chen <[email protected]>
Add a new compatible string for imx93.
--- Documentation/devicetree/bindings/net/can/fsl,flexcan.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/net/can/fsl,flexcan.yaml +1 -0
@@ -17,6 +17,7 @@ properties: compatible: oneOf: - enum: + - fsl,imx93-flexcan - fsl,imx8qm-flexcan - fsl,imx8mp-flexcan - fsl,imx6q-flexcan
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 14/39 can: etas_es58x: add devlink port support
In reply to Marc Kleine-BuddeFrom: Vincent Mailhol <[email protected]>
Add support for devlink port which extends the devlink support to the network interface level. For now, the etas_es58x driver will only rely on the default features that devlink port has to offer and not implement additional feature ones.
--- drivers/net/can/usb/etas_es58x/es58x_core.c | 34 ++++++++++++++++----- drivers/net/can/usb/etas_es58x/es58x_core.h | 3 ++ 2 files changed, 29 insertions(+), 8 deletions(-)
drivers/net/can/usb/etas_es58x/es58x_core.c +26 -8
@@ -2039,10 +2039,16 @@ static int es58x_set_mode(struct net_device *netdev, enum can_mode mode)* @es58x_dev: ES58X device. * @priv: ES58X private parameters related to the network device. * @channel_idx: Index of the network device. +* +* Return: zero on success, errno if devlink port could not be +* properly registered. */ -static void es58x_init_priv (struct es58x_device *es58x_dev, -struct es58x_priv *priv,int channel_idx) +static int es58x_init_priv (struct es58x_device *es58x_dev, +struct es58x_priv *priv,int channel_idx) { +struct devlink_port_attrs attrs = { + .flavour =DEVLINK_PORT_FLAVOUR_PHYSICAL , + };const struct es58x_parameters *param = es58x_dev->param;struct can_priv *can = &priv->can;
@@ -2061,6 +2067,10 @@ static void es58x_init_priv(struct es58x_device *es58x_dev, can->state =CAN_STATE_STOPPED ; can->ctrlmode_supported = param->ctrlmode_supported; can->do_set_mode = es58x_set_mode; + +devlink_port_attrs_set (&priv->devlink_port, &attrs); +return devlink_port_register (priv_to_devlink (es58x_dev), + &priv->devlink_port, channel_idx); }/**
@@ -2084,7 +2094,10 @@ static int es58x_init_netdev(struct es58x_device *es58x_dev, int channel_idx) }SET_NETDEV_DEV (netdev, dev); es58x_dev->netdev[channel_idx] = netdev; -es58x_init_priv (es58x_dev,es58x_priv (netdev), channel_idx); + ret =es58x_init_priv (es58x_dev,es58x_priv (netdev), channel_idx); +if (ret) + goto free_candev; +SET_NETDEV_DEVLINK_PORT (netdev, &es58x_priv (netdev)->devlink_port); netdev->netdev_ops = &es58x_netdev_ops; netdev->ethtool_ops = &es58x_ethtool_ops;
@@ -2092,16 +2105,20 @@ static int es58x_init_netdev(struct es58x_device *es58x_dev, int channel_idx) netdev->dev_port = channel_idx; ret =register_candev (netdev); -if (ret) { - es58x_dev->netdev[channel_idx] =NULL ; -free_candev (netdev); -return ret; - } +if (ret) + goto devlink_port_unregister;netdev_queue_set_dql_min_limit (netdev_get_tx_queue (netdev,0 ), es58x_dev->param->dql_min_limit);return ret; + + devlink_port_unregister: +devlink_port_unregister (&es58x_priv (netdev)->devlink_port); + free_candev: + es58x_dev->netdev[channel_idx] =NULL ; +free_candev (netdev); +return ret; }/**
@@ -2118,6 +2135,7 @@ static void es58x_free_netdevs(struct es58x_device *es58x_dev)if (!netdev)continue ;unregister_candev (netdev); +devlink_port_unregister (&es58x_priv (netdev)->devlink_port); es58x_dev->netdev[i] =NULL ;free_candev (netdev); }
drivers/net/can/usb/etas_es58x/es58x_core.h +3 -0
@@ -17,6 +17,7 @@#include <linux/netdevice.h> #include <linux/types.h> #include <linux/usb.h> +#include <net/devlink.h> #include "es581_4.h" #include "es58x_fd.h"
@@ -230,6 +231,7 @@ union es58x_urb_cmd {* @can: struct can_priv must be the first member (Socket CAN relies * on the fact that function netdev_priv() returns a pointer to * a struct can_priv). +* @devlink_port: devlink instance for the network interface. * @es58x_dev: pointer to the corresponding ES58X device. * @tx_urb: Used as a buffer to concatenate the TX messages and to do * a bulk send. Please refer to es58x_start_xmit() for more
@@ -255,6 +257,7 @@ union es58x_urb_cmd {*/ struct es58x_priv {struct can_priv can; +struct devlink_port devlink_port;struct es58x_device *es58x_dev;struct urb *tx_urb;
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 15/39 dt-bindings: can: renesas,rcar-canfd: Document RZ/Five SoC
In reply to Marc Kleine-BuddeFrom: Lad Prabhakar <[email protected]>
The CANFD block on the RZ/Five SoC is identical to one found on the RZ/G2UL SoC. "renesas,r9a07g043-canfd" compatible string will be used on the RZ/Five SoC so to make this clear, update the comment to include RZ/Five SoC.
No driver changes are required as generic compatible string "renesas,rzg2l-canfd" will be used as a fallback on RZ/Five SoC.
--- .../devicetree/bindings/net/can/renesas,rcar-canfd.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml +1 -1
@@ -33,7 +33,7 @@ properties: - items: - enum: - - renesas,r9a07g043-canfd # RZ/G2UL + - renesas,r9a07g043-canfd # RZ/G2UL and RZ/Five - renesas,r9a07g044-canfd # RZ/G2{L,LC} - renesas,r9a07g054-canfd # RZ/V2L - const: renesas,rzg2l-canfd # RZ/G2L family
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 16/39 USB: core: export usb_cache_string()
In reply to Marc Kleine-BuddeFrom: Vincent Mailhol <[email protected]>
usb_cache_string() can also be useful for the drivers so export it.
--- drivers/usb/core/message.c | 1 + drivers/usb/core/usb.h | 1 - include/linux/usb.h | 1 + 3 files changed, 2 insertions(+), 1 deletion(-)
drivers/usb/core/message.c +1 -0
@@ -1037,6 +1037,7 @@ char *usb_cache_string(struct usb_device *udev, int index) }return smallbuf; } +EXPORT_SYMBOL_GPL (usb_cache_string);/* * usb_get_device_descriptor - (re)reads the device descriptor (usbcore)
drivers/usb/core/usb.h +0 -1
@@ -47,7 +47,6 @@ extern int usb_get_device_descriptor(struct usb_device *dev,extern int usb_set_isoch_delay (struct usb_device *dev);extern int usb_get_bos_descriptor (struct usb_device *dev);extern void usb_release_bos_descriptor (struct usb_device *dev); -extern char *usb_cache_string (struct usb_device *udev,int index);extern int usb_set_configuration (struct usb_device *dev,int configuration);extern int usb_choose_configuration (struct usb_device *udev);extern int usb_generic_driver_probe (struct usb_device *udev);
include/linux/usb.h +1 -0
@@ -1829,6 +1829,7 @@ static inline int usb_get_ptm_status(struct usb_device *dev, void *data)extern int usb_string (struct usb_device *dev,int index,char *buf,size_t size); +extern char *usb_cache_string (struct usb_device *udev,int index);/* wrappers that also update important state inside usbcore */ extern int usb_clear_halt (struct usb_device *dev,int pipe);
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 17/39 can: c_can: use devm_platform_get_and_ioremap_resource()
In reply to Marc Kleine-BuddeFrom: Minghao Chi <[email protected]>
Convert platform_get_resource(), devm_ioremap_resource() to a single call to devm_platform_get_and_ioremap_resource(), as this is exactly what this function does.
--- drivers/net/can/c_can/c_can_platform.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/can/c_can/c_can_platform.c +1 -2
@@ -290,8 +290,7 @@ static int c_can_plat_probe(struct platform_device *pdev) goto exit; } - mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - addr =devm_ioremap_resource (&pdev->dev, mem); + addr =devm_platform_get_and_ioremap_resource (pdev,0 , &mem);if (IS_ERR (addr)) { ret =PTR_ERR (addr); goto exit;
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 18/39 net: devlink: add DEVLINK_INFO_VERSION_GENERIC_FW_BOOTLOADER
In reply to Marc Kleine-BuddeFrom: Vincent Mailhol <[email protected]>
As discussed in [1], abbreviating the bootloader to "bl" might not be well understood. Instead, a bootloader technically being a firmware, name it "fw.bootloader".
Add a new macro to devlink.h to formalize this new info attribute name and update the documentation.
[1] https://lore.kernel.org/netdev/[email protected]/
--- Documentation/networking/devlink/devlink-info.rst | 5 +++++ include/net/devlink.h | 2 ++ 2 files changed, 7 insertions(+)
Documentation/networking/devlink/devlink-info.rst +5 -0
@@ -198,6 +198,11 @@ fw.bundle_id Unique identifier of the entire firmware bundle. +fw.bootloader +------------- + +Version of the bootloader. + Future work ===========
include/net/devlink.h +2 -0
@@ -621,6 +621,8 @@ enum devlink_param_generic_id {#define DEVLINK_INFO_VERSION_GENERIC_FW_ROCE "fw.roce"/* Firmware bundle identifier */ #define DEVLINK_INFO_VERSION_GENERIC_FW_BUNDLE_ID "fw.bundle_id" +/* Bootloader */ +#define DEVLINK_INFO_VERSION_GENERIC_FW_BOOTLOADER "fw.bootloader"/** * struct devlink_flash_update_params - Flash Update parameters
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 19/39 can: etas_es58x: export product information through devlink_ops::info_get()
In reply to Marc Kleine-BuddeFrom: Vincent Mailhol <[email protected]>
ES58x devices report below product information through a custom usb string:
* the firmware version
* the bootloader version
* the hardware revision
Parse this string, store the results in struct es58x_dev, export:
* the firmware version through devlink's "fw" name
* the bootloader version through devlink's "fw.bootloader" name
* the hardware revisionthrough devlink's "board.rev" name
Those devlink entries are not critical to use the device, if parsing fails, print an informative log message and continue to probe the device.
In addition to that, use usb_device::serial to report the device serial number.
--- drivers/net/can/usb/etas_es58x/es58x_core.c | 1 + drivers/net/can/usb/etas_es58x/es58x_core.h | 41 ++++ .../net/can/usb/etas_es58x/es58x_devlink.c | 222 ++++++++++++++++++ 3 files changed, 264 insertions(+)
drivers/net/can/usb/etas_es58x/es58x_core.c +1 -0
@@ -2271,6 +2271,7 @@ static int es58x_probe(struct usb_interface *intf,if (ret)return ret; +es58x_parse_product_info (es58x_dev);devlink_register (priv_to_devlink (es58x_dev));for (ch_idx =0 ; ch_idx < es58x_dev->num_can_ch; ch_idx++) {
drivers/net/can/usb/etas_es58x/es58x_core.h +41 -0
65 lines not on this page · raw message
drivers/net/can/usb/etas_es58x/es58x_devlink.c +222 -0
229 lines not on this page · raw message
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 20/39 can: etas_es58x: remove es58x_get_product_info()
In reply to Marc Kleine-BuddeFrom: Vincent Mailhol <[email protected]>
Now that the product information are available under devlink, no more need to print them in the kernel log. Remove es58x_get_product_info().
--- drivers/net/can/usb/etas_es58x/es58x_core.c | 52 ++------------------- 1 file changed, 3 insertions(+), 49 deletions(-)
drivers/net/can/usb/etas_es58x/es58x_core.c +3 -49
@@ -2141,48 +2141,6 @@ static void es58x_free_netdevs(struct es58x_device *es58x_dev) } } -/** -* es58x_get_product_info() - Get the product information and print them. -* @es58x_dev: ES58X device. -* -* Do a synchronous call to get the product information. -* -* Return: zero on success, errno when any error occurs. -*/ -static int es58x_get_product_info (struct es58x_device *es58x_dev) -{ -struct usb_device *udev = es58x_dev->udev; -const int es58x_prod_info_idx =6 ; -/* Empirical tests show a prod_info length of maximum 83, -* below should be more than enough. -*/ -const size_t prod_info_len =127 ; -char *prod_info; -int ret; - - prod_info =kmalloc (prod_info_len,GFP_KERNEL ); -if (!prod_info) -return -ENOMEM ; - - ret =usb_string (udev, es58x_prod_info_idx, prod_info, prod_info_len); -if (ret <0 ) { -dev_err (es58x_dev->dev, -"%s: Could not read the product info: %pe\n" , - __func__,ERR_PTR (ret)); - goto out_free; - } -if (ret >= prod_info_len -1 ) { -dev_warn (es58x_dev->dev, -"%s: Buffer is too small, result might be truncated\n" , - __func__); - } -dev_info (es58x_dev->dev,"Product info: %s\n" , prod_info); - - out_free: -kfree (prod_info); -return ret <0 ? ret :0 ; -} -/** * es58x_init_es58x_dev() - Initialize the ES58X device. * @intf: USB interface.
@@ -2261,28 +2219,24 @@ static int es58x_probe(struct usb_interface *intf, const struct usb_device_id *id) {struct es58x_device *es58x_dev; -int ch_idx, ret; +int ch_idx; es58x_dev =es58x_init_es58x_dev (intf, id->driver_info);if (IS_ERR (es58x_dev))return PTR_ERR (es58x_dev); - ret =es58x_get_product_info (es58x_dev); -if (ret) -return ret; -es58x_parse_product_info (es58x_dev);devlink_register (priv_to_devlink (es58x_dev));for (ch_idx =0 ; ch_idx < es58x_dev->num_can_ch; ch_idx++) { - ret =es58x_init_netdev (es58x_dev, ch_idx); +int ret =es58x_init_netdev (es58x_dev, ch_idx);if (ret) {es58x_free_netdevs (es58x_dev);return ret; } } -return ret; +return 0 ; }/**
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 21/39 Documentation: devlink: add devlink documentation for the etas_es58x driver
In reply to Marc Kleine-BuddeFrom: Vincent Mailhol <[email protected]>
List all the version information reported by the etas_es58x driver through devlink. Also, update MAINTAINERS with the newly created file.
[mkl: fixed version information table: "bl" -> "fw.bootloader"
--- .../networking/devlink/etas_es58x.rst | 36 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 37 insertions(+) create mode 100644 Documentation/networking/devlink/etas_es58x.rst
Documentation/networking/devlink/etas_es58x.rst new file +36 -0
@@ -0,0 +1,36 @@ +.. SPDX-License-Identifier: GPL-2.0 + +========================== +etas_es58x devlink support +========================== + +This document describes the devlink features implemented by the +``etas_es58x`` device driver. + +Info versions +============= + +The ``etas_es58x`` driver reports the following versions + +.. list-table:: devlink info versions implemented + :widths: 5 5 90 + + * - Name + - Type + - Description + * - ``fw`` + - running + - Version of the firmware running on the device. Also available + through ``ethtool -i`` as the first member of the + ``firmware-version``. + * - ``fw.bootloader`` + - running + - Version of the bootloader running on the device. Also available + through ``ethtool -i`` as the second member of the + ``firmware-version``. + * - ``board.rev`` + - fixed + - The hardware revision of the device. + * - ``serial_number`` + - fixed + - The USB serial number. Also available through ``lsusb -v``.
MAINTAINERS +1 -0
@@ -7682,6 +7682,7 @@ ETAS ES58X CAN/USB DRIVER M: Vincent Mailhol <[email protected]> L: [email protected] S: Maintained +F: Documentation/networking/devlink/etas_es58x.rst F: drivers/net/can/usb/etas_es58x/ ETHERNET BRIDGE
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 22/39 can: ucan: use strscpy() to instead of strncpy()
In reply to Marc Kleine-BuddeFrom: Xu Panda <[email protected]>
The implementation of strscpy() is more robust and safer. That's now the recommended way to copy NUL terminated strings.
--- drivers/net/can/usb/ucan.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/can/usb/ucan.c +2 -3
@@ -1534,9 +1534,8 @@ static int ucan_probe(struct usb_interface *intf, sizeof(union ucan_ctl_payload));if (ret >0 ) {/* copy string while ensuring zero termination */ -strncpy (firmware_str, up->ctl_msg_buffer->raw, -sizeof (union ucan_ctl_payload )); - firmware_str[sizeof (union ucan_ctl_payload )] ='\0' ; +strscpy (firmware_str, up->ctl_msg_buffer->raw, +sizeof (union ucan_ctl_payload ) +1 ); }else {strcpy (firmware_str,"unknown" ); }
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 23/39 net: af_can: remove useless parameter 'err' in 'can_rx_register()'
In reply to Marc Kleine-BuddeFrom: Ye Bin <[email protected]>
Since commit bdfb5765e45b remove NULL-ptr checks from users of can_dev_rcv_lists_find(). 'err' parameter is useless, so remove it.
--- net/can/af_can.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/can/af_can.c +1 -2
@@ -446,7 +446,6 @@ int can_rx_register(struct net *net, struct net_device *dev, canid_t can_id,struct hlist_head *rcv_list;struct can_dev_rcv_lists *dev_rcv_lists;struct can_rcv_lists_stats *rcv_lists_stats = net->can.rcv_lists_stats; -int err =0 ;/* insert new receiver (dev,canid,mask) -> (func,data) */
@@ -481,7 +480,7 @@ int can_rx_register(struct net *net, struct net_device *dev, canid_t can_id, rcv_lists_stats->rcv_entries);spin_unlock_bh (&net->can.rcvlists_lock); -return err; +return 0 ; }EXPORT_SYMBOL (can_rx_register);
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 24/39 can: ucan: remove unused ucan_priv::intf
In reply to Marc Kleine-BuddeFrom: Vincent Mailhol <[email protected]>
Field intf of struct ucan_priv is set but never used. Remove it.
--- drivers/net/can/usb/ucan.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/can/usb/ucan.c +0 -2
@@ -277,7 +277,6 @@ struct ucan_priv {/* linux USB device structures */ struct usb_device *udev; -struct usb_interface *intf;struct net_device *netdev;/* lock for can->echo_skb (used around
@@ -1501,7 +1500,6 @@ static int ucan_probe(struct usb_interface *intf,/* initialize data */ up->udev = udev; - up->intf = intf; up->netdev = netdev; up->intf_index = iface_desc->desc.bInterfaceNumber; up->in_ep_addr = in_ep_addr;
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 25/39 can: gs_usb: remove gs_can::iface
In reply to Marc Kleine-BuddeFrom: Vincent Mailhol <[email protected]>
The iface field of struct gs_can is only used to retrieve the usb_device which is already available in gs_can::udev.
Replace each occurrence of interface_to_usbdev(dev->iface) with dev->udev. This done, remove gs_can::iface.
--- drivers/net/can/usb/gs_usb.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-)
drivers/net/can/usb/gs_usb.c +9 -20
@@ -299,7 +299,6 @@ struct gs_can {struct net_device *netdev;struct usb_device *udev; -struct usb_interface *iface;struct can_bittiming_const bt_const, data_bt_const;unsigned int channel;/* channel number */
@@ -383,8 +382,7 @@ static int gs_cmd_reset(struct gs_can *dev) .mode = GS_CAN_MODE_RESET, }; -return usb_control_msg_send (interface_to_usbdev (dev->iface),0 , -GS_USB_BREQ_MODE , +return usb_control_msg_send (dev->udev,0 ,GS_USB_BREQ_MODE ,USB_DIR_OUT |USB_TYPE_VENDOR |USB_RECIP_INTERFACE , dev->channel,0 , &dm,sizeof (dm),1000 ,GFP_KERNEL );
@@ -396,8 +394,7 @@ static inline int gs_usb_get_timestamp(const struct gs_can *dev,__le32 timestamp;int rc; - rc = usb_control_msg_recv(interface_to_usbdev(dev->iface), 0, - GS_USB_BREQ_TIMESTAMP, + rc = usb_control_msg_recv(dev->udev, 0, GS_USB_BREQ_TIMESTAMP, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, dev->channel, 0, ×tamp, sizeof(timestamp),
@@ -674,8 +671,7 @@ static int gs_usb_set_bittiming(struct net_device *netdev) };/* request bit timings */ -return usb_control_msg_send (interface_to_usbdev (dev->iface),0 , -GS_USB_BREQ_BITTIMING , +return usb_control_msg_send (dev->udev,0 ,GS_USB_BREQ_BITTIMING ,USB_DIR_OUT |USB_TYPE_VENDOR |USB_RECIP_INTERFACE , dev->channel,0 , &dbt,sizeof (dbt),1000 ,GFP_KERNEL );
@@ -698,8 +694,7 @@ static int gs_usb_set_data_bittiming(struct net_device *netdev) request =GS_USB_BREQ_QUIRK_CANTACT_PRO_DATA_BITTIMING ;/* request data bit timings */ -return usb_control_msg_send (interface_to_usbdev (dev->iface),0 , - request, +return usb_control_msg_send (dev->udev,0 , request,USB_DIR_OUT |USB_TYPE_VENDOR |USB_RECIP_INTERFACE , dev->channel,0 , &dbt,sizeof (dbt),1000 ,GFP_KERNEL );
@@ -941,8 +936,7 @@ static int gs_can_open(struct net_device *netdev)/* finally start device */ dev->can.state =CAN_STATE_ERROR_ACTIVE ; dm.flags =cpu_to_le32 (flags); - rc =usb_control_msg_send (interface_to_usbdev (dev->iface),0 , -GS_USB_BREQ_MODE , + rc =usb_control_msg_send (dev->udev,0 ,GS_USB_BREQ_MODE ,USB_DIR_OUT |USB_TYPE_VENDOR |USB_RECIP_INTERFACE , dev->channel,0 , &dm,sizeof (dm),1000 ,GFP_KERNEL );
@@ -969,8 +963,7 @@ static int gs_usb_get_state(const struct net_device *netdev,struct gs_device_state ds;int rc; - rc = usb_control_msg_recv(interface_to_usbdev(dev->iface), 0, - GS_USB_BREQ_GET_STATE, + rc = usb_control_msg_recv(dev->udev, 0, GS_USB_BREQ_GET_STATE, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, dev->channel, 0, &ds, sizeof(ds),
@@ -1064,8 +1057,7 @@ static int gs_usb_set_identify(struct net_device *netdev, bool do_identify)else imode.mode =cpu_to_le32 (GS_CAN_IDENTIFY_OFF ); -return usb_control_msg_send (interface_to_usbdev (dev->iface),0 , -GS_USB_BREQ_IDENTIFY , +return usb_control_msg_send (dev->udev,0 ,GS_USB_BREQ_IDENTIFY ,USB_DIR_OUT |USB_TYPE_VENDOR |USB_RECIP_INTERFACE , dev->channel,0 , &imode,sizeof (imode),100 ,GFP_KERNEL );
@@ -1118,8 +1110,7 @@ static int gs_usb_get_termination(struct net_device *netdev, u16 *term)struct gs_device_termination_state term_state;int rc; - rc = usb_control_msg_recv(interface_to_usbdev(dev->iface), 0, - GS_USB_BREQ_GET_TERMINATION, + rc = usb_control_msg_recv(dev->udev, 0, GS_USB_BREQ_GET_TERMINATION, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, dev->channel, 0, &term_state, sizeof(term_state), 1000,
@@ -1145,8 +1136,7 @@ static int gs_usb_set_termination(struct net_device *netdev, u16 term)else term_state.state =cpu_to_le32 (GS_CAN_TERMINATION_STATE_OFF ); - return usb_control_msg_send(interface_to_usbdev(dev->iface), 0, - GS_USB_BREQ_SET_TERMINATION, + return usb_control_msg_send(dev->udev, 0, GS_USB_BREQ_SET_TERMINATION, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, dev->channel, 0, &term_state, sizeof(term_state), 1000,
@@ -1210,7 +1200,6 @@ static struct gs_can *gs_make_candev(unsigned int channel, dev->bt_const.brp_inc =le32_to_cpu (bt_const.brp_inc); dev->udev =interface_to_usbdev (intf); - dev->iface = intf; dev->netdev = netdev; dev->channel = channel;
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 26/39 can: m_can: Call the RAM init directly from m_can_chip_config
In reply to Marc Kleine-BuddeFrom: Vivek Yadav <[email protected]>
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.
--- drivers/net/can/m_can/m_can.c | 32 +++++++++++++++++++++----- drivers/net/can/m_can/m_can_platform.c | 4 ---- drivers/net/can/m_can/tcan4x5x-core.c | 5 ---- 3 files changed, 26 insertions(+), 15 deletions(-)
drivers/net/can/m_can/m_can.c +26 -6
@@ -1243,10 +1243,17 @@ static int m_can_set_bittiming(struct net_device *dev)* - setup bittiming * - configure timestamp generation */ -static void m_can_chip_config (struct net_device *dev) +static int m_can_chip_config (struct net_device *dev) {struct m_can_classdev *cdev =netdev_priv (dev);u32 cccr, test; +int err; + + err =m_can_init_ram (cdev); +if (err) { +dev_err (cdev->dev,"Message RAM configuration failed\n" ); +return err; + }m_can_config_endisable (cdev, true);
@@ -1370,18 +1377,25 @@ static void m_can_chip_config(struct net_device *dev)if (cdev->ops->init) cdev->ops->init (cdev); + +return 0 ; } -static void m_can_start (struct net_device *dev) +static int m_can_start (struct net_device *dev) {struct m_can_classdev *cdev =netdev_priv (dev); +int ret;/* basic m_can configuration */ -m_can_chip_config (dev); + ret =m_can_chip_config (dev); +if (ret) +return ret; cdev->can.state =CAN_STATE_ERROR_ACTIVE ;m_can_enable_all_interrupts (cdev); + +return 0 ; }static int m_can_set_mode (struct net_device *dev,enum can_mode mode)
@@ -1809,7 +1823,9 @@ static int m_can_open(struct net_device *dev) }/* start the m_can controller */ -m_can_start (dev); + err =m_can_start (dev); +if (err) + goto exit_irq_fail;if (!cdev->is_peripheral)napi_enable (&cdev->napi);
@@ -2068,9 +2084,13 @@ int m_can_class_resume(struct device *dev) ret =m_can_clk_start (cdev);if (ret)return ret; + ret =m_can_start (ndev); +if (ret) { +m_can_clk_stop (cdev); + +return ret; + } -m_can_init_ram (cdev); -m_can_start (ndev);netif_device_attach (ndev);netif_start_queue (ndev); }
drivers/net/can/m_can/m_can_platform.c +0 -4
@@ -140,10 +140,6 @@ static int m_can_plat_probe(struct platform_device *pdev)platform_set_drvdata (pdev, mcan_class); - ret =m_can_init_ram (mcan_class); -if (ret) - goto probe_fail; -pm_runtime_enable (mcan_class->dev); ret =m_can_class_register (mcan_class);if (ret)
drivers/net/can/m_can/tcan4x5x-core.c +0 -5
@@ -234,11 +234,6 @@ static int tcan4x5x_init(struct m_can_classdev *cdev)if (ret)return ret; -/* Zero out the MCAN buffers */ - ret =m_can_init_ram (cdev); -if (ret) -return ret; - ret =regmap_update_bits (tcan4x5x->regmap,TCAN4X5X_CONFIG ,TCAN4X5X_MODE_SEL_MASK ,TCAN4X5X_MODE_NORMAL );if (ret)
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 27/39 can: raw: add support for SO_MARK
In reply to Marc Kleine-BuddeAdd support for SO_MARK to the CAN_RAW protocol. This makes it possible to add traffic control filters based on the fwmark.
--- net/can/raw.c | 1 + 1 file changed, 1 insertion(+)
net/can/raw.c +1 -0
@@ -857,6 +857,7 @@ static int raw_sendmsg(struct socket *sock, struct msghdr *msg, size_t size) skb->dev = dev; skb->priority = sk->sk_priority; + skb->mark = sk->sk_mark; skb->tstamp = sockc.transmit_time;skb_setup_tx_timestamp (skb, sockc.tsflags);
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 28/39 dt-bindings: can: renesas,rcar-canfd: Fix number of channels for R-Car V3U
In reply to Marc Kleine-BuddeFrom: Geert Uytterhoeven <[email protected]>
According to the bindings, only two channels are supported. However, R-Car V3U supports eight, leading to "make dtbs" failures:
arch/arm64/boot/dts/renesas/r8a779a0-falcon.dtb: can@e6660000: Unevaluated properties are not allowed ('channel2', 'channel3', 'channel4', 'channel5', 'channel6', 'channel7' were unexpected)Update the number of channels to 8 on R-Car V3U.
While at it, prevent adding more properties to the channel nodes, as they must contain no other properties than a status property.
--- .../bindings/net/can/renesas,rcar-canfd.yaml | 133 ++++++++++-------- 1 file changed, 72 insertions(+), 61 deletions(-)
Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml +72 -61
@@ -9,9 +9,6 @@ title: Renesas R-Car CAN FD Controller maintainers: - Fabrizio Castro <[email protected]> -allOf: - - $ref: can-controller.yaml# - properties: compatible: oneOf:
@@ -77,12 +74,13 @@ properties: description: Maximum frequency of the CANFD clock. patternProperties: - "^channel[01]$": + "^channel[0-7]$": type: object description: - The controller supports two channels and each is represented as a child - node. Each child node supports the "status" property only, which - is used to enable/disable the respective channel. + The controller supports multiple channels and each is represented as a + child node. Each channel can be enabled/disabled individually. + + additionalProperties: false required: - compatible
@@ -98,60 +96,73 @@ required: - channel0 - channel1 -if: - properties: - compatible: - contains: - enum: - - renesas,rzg2l-canfd -then: - properties: - interrupts: - items: - - description: CAN global error interrupt - - description: CAN receive FIFO interrupt - - description: CAN0 error interrupt - - description: CAN0 transmit interrupt - - description: CAN0 transmit/receive FIFO receive completion interrupt - - description: CAN1 error interrupt - - description: CAN1 transmit interrupt - - description: CAN1 transmit/receive FIFO receive completion interrupt - - interrupt-names: - items: - - const: g_err - - const: g_recc - - const: ch0_err - - const: ch0_rec - - const: ch0_trx - - const: ch1_err - - const: ch1_rec - - const: ch1_trx - - resets: - maxItems: 2 - - reset-names: - items: - - const: rstp_n - - const: rstc_n - - required: - - reset-names -else: - properties: - interrupts: - items: - - description: Channel interrupt - - description: Global interrupt - - interrupt-names: - items: - - const: ch_int - - const: g_int - - resets: - maxItems: 1 +allOf: + - $ref: can-controller.yaml# + + - if: + properties: + compatible: + contains: + enum: + - renesas,rzg2l-canfd + then: + properties: + interrupts: + items: + - description: CAN global error interrupt + - description: CAN receive FIFO interrupt + - description: CAN0 error interrupt + - description: CAN0 transmit interrupt + - description: CAN0 transmit/receive FIFO receive completion interrupt + - description: CAN1 error interrupt + - description: CAN1 transmit interrupt + - description: CAN1 transmit/receive FIFO receive completion interrupt + + interrupt-names: + items: + - const: g_err + - const: g_recc + - const: ch0_err + - const: ch0_rec + - const: ch0_trx + - const: ch1_err + - const: ch1_rec + - const: ch1_trx + + resets: + maxItems: 2 + + reset-names: + items: + - const: rstp_n + - const: rstc_n + + required: + - reset-names + else: + properties: + interrupts: + items: + - description: Channel interrupt + - description: Global interrupt + + interrupt-names: + items: + - const: ch_int + - const: g_int + + resets: + maxItems: 1 + + - if: + not: + properties: + compatible: + contains: + const: renesas,r8a779a0-canfd + then: + patternProperties: + "^channel[2-7]$": false unevaluatedProperties: false
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 29/39 can: m_can: Eliminate double read of TXFQS in tx_handler
In reply to Marc Kleine-BuddeFrom: Markus Schneider-Pargmann <[email protected]>
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.
--- drivers/net/can/m_can/m_can.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/net/can/m_can/m_can.c +11 -4
@@ -369,9 +369,14 @@ m_can_txe_fifo_read(struct m_can_classdev *cdev, u32 fgi, u32 offset, u32 *val)return cdev->ops->read_fifo (cdev, addr_offset, val,1 ); } +static inline bool _m_can_tx_fifo_full (u32 txfqs) +{ +return !!(txfqs &TXFQS_TFQF ); +} +static inline bool m_can_tx_fifo_full (struct m_can_classdev *cdev) { -return !!(m_can_read (cdev,M_CAN_TXFQS ) &TXFQS_TFQF ); +return _m_can_tx_fifo_full (m_can_read (cdev,M_CAN_TXFQS )); }static void m_can_config_endisable (struct m_can_classdev *cdev,bool enable)
@@ -1609,6 +1614,7 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev)struct sk_buff *skb = cdev->tx_skb;struct id_and_dlc fifo_header;u32 cccr, fdflags; +u32 txfqs;int err;int putidx;
@@ -1665,8 +1671,10 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev) }else {/* Transmit routine for version >= v3.1.x */ + txfqs =m_can_read (cdev,M_CAN_TXFQS ); +/* Check if FIFO full */ -if (m_can_tx_fifo_full (cdev)) { +if (_m_can_tx_fifo_full (txfqs)) {/* This shouldn't happen */ netif_stop_queue (dev); netdev_warn(dev,
@@ -1682,8 +1690,7 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev) }/* get put index for frame */ - putidx =FIELD_GET (TXFQS_TFQPI_MASK , -m_can_read (cdev,M_CAN_TXFQS )); + putidx =FIELD_GET (TXFQS_TFQPI_MASK , txfqs);/* Construct DLC Field, with CAN-FD configuration. * Use the put index of the fifo as the message marker,
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 30/39 can: m_can: Avoid reading irqstatus twice
In reply to Marc Kleine-BuddeFrom: Markus Schneider-Pargmann <[email protected]>
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.
--- drivers/net/can/m_can/m_can.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/net/can/m_can/m_can.c +9 -7
@@ -905,14 +905,13 @@ static int m_can_handle_bus_errors(struct net_device *dev, u32 irqstatus,return work_done; } -static int m_can_rx_handler (struct net_device *dev,int quota) +static int m_can_rx_handler (struct net_device *dev,int quota,u32 irqstatus) {struct m_can_classdev *cdev =netdev_priv (dev);int rx_work_or_err;int work_done =0 ; -u32 irqstatus, psr; +u32 psr; - irqstatus = cdev->irqstatus |m_can_read (cdev,M_CAN_IR );if (!irqstatus) goto end;
@@ -956,12 +955,12 @@ static int m_can_rx_handler(struct net_device *dev, int quota)return work_done; } -static int m_can_rx_peripheral (struct net_device *dev) +static int m_can_rx_peripheral (struct net_device *dev,u32 irqstatus) {struct m_can_classdev *cdev =netdev_priv (dev);int work_done; - work_done =m_can_rx_handler (dev,NAPI_POLL_WEIGHT ); + work_done =m_can_rx_handler (dev,NAPI_POLL_WEIGHT , irqstatus);/* Don't re-enable interrupts if the driver had a fatal error * (e.g., FIFO read failure).
@@ -977,8 +976,11 @@ static int m_can_poll(struct napi_struct *napi, int quota)struct net_device *dev = napi->dev;struct m_can_classdev *cdev =netdev_priv (dev);int work_done; +u32 irqstatus; + + irqstatus = cdev->irqstatus |m_can_read (cdev,M_CAN_IR ); - work_done =m_can_rx_handler (dev, quota); + work_done =m_can_rx_handler (dev, quota, irqstatus);/* Don't re-enable interrupts if the driver had a fatal error * (e.g., FIFO read failure).
@@ -1088,7 +1090,7 @@ static irqreturn_t m_can_isr(int irq, void *dev_id)m_can_disable_all_interrupts (cdev);if (!cdev->is_peripheral)napi_schedule (&cdev->napi); -else if (m_can_rx_peripheral (dev) <0 ) +else if (m_can_rx_peripheral (dev, ir) <0 ) goto out_fail; }
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 31/39 can: m_can: Read register PSR only on error
In reply to Marc Kleine-BuddeFrom: Markus Schneider-Pargmann <[email protected]>
Only read register PSR if there is an error indicated in irqstatus.
--- drivers/net/can/m_can/m_can.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/net/can/m_can/m_can.c +4 -5
@@ -910,7 +910,6 @@ static int m_can_rx_handler(struct net_device *dev, int quota, u32 irqstatus)struct m_can_classdev *cdev =netdev_priv (dev);int rx_work_or_err;int work_done =0 ; -u32 psr;if (!irqstatus) goto end;
@@ -936,13 +935,13 @@ static int m_can_rx_handler(struct net_device *dev, int quota, u32 irqstatus) } } - psr =m_can_read (cdev,M_CAN_PSR ); -if (irqstatus &IR_ERR_STATE ) - work_done +=m_can_handle_state_errors (dev, psr); + work_done +=m_can_handle_state_errors (dev, +m_can_read (cdev,M_CAN_PSR ));if (irqstatus &IR_ERR_BUS_30X ) - work_done +=m_can_handle_bus_errors (dev, irqstatus, psr); + work_done +=m_can_handle_bus_errors (dev, irqstatus, +m_can_read (cdev,M_CAN_PSR ));if (irqstatus &IR_RF0N ) { rx_work_or_err =m_can_do_rx_poll (dev, (quota - work_done));
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 32/39 can: m_can: Count TXE FIFO getidx in the driver
In reply to Marc Kleine-BuddeFrom: Markus Schneider-Pargmann <[email protected]>
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.
--- drivers/net/can/m_can/m_can.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/can/m_can/m_can.c +2 -3
@@ -1030,15 +1030,13 @@ static int m_can_echo_tx_event(struct net_device *dev)/* Get Tx Event fifo element count */ txe_count =FIELD_GET (TXEFS_EFFL_MASK , m_can_txefs); + fgi =FIELD_GET (TXEFS_EFGI_MASK , m_can_txefs);/* Get and process all sent elements */ for (i =0 ; i < txe_count; i++) {u32 txe, timestamp =0 ;int err; -/* retrieve get index */ - fgi =FIELD_GET (TXEFS_EFGI_MASK ,m_can_read (cdev,M_CAN_TXEFS )); -/* get message marker, timestamp */ err =m_can_txe_fifo_read (cdev, fgi,4 , &txe);if (err) {
@@ -1052,6 +1050,7 @@ static int m_can_echo_tx_event(struct net_device *dev)/* ack txe element */ m_can_write (cdev,M_CAN_TXEFA ,FIELD_PREP (TXEFA_EFAI_MASK , fgi)); + fgi = (++fgi >= cdev->mcfg[MRAM_TXE ].num ?0 : fgi);/* update stats */ m_can_tx_update_stats (cdev, msg_mark, timestamp);
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 33/39 can: m_can: Count read getindex in the driver
In reply to Marc Kleine-BuddeFrom: Markus Schneider-Pargmann <[email protected]>
The getindex gets increased by one every time. We can calculate the correct getindex in the driver and avoid the additional reads of rxfs.
--- drivers/net/can/m_can/m_can.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/net/can/m_can/m_can.c +10 -7
@@ -477,19 +477,16 @@ static void m_can_receive_skb(struct m_can_classdev *cdev, } } -static int m_can_read_fifo (struct net_device *dev,u32 rxfs) +static int m_can_read_fifo (struct net_device *dev,u32 fgi) {struct net_device_stats *stats = &dev->stats;struct m_can_classdev *cdev =netdev_priv (dev);struct canfd_frame *cf;struct sk_buff *skb;struct id_and_dlc fifo_header; -u32 fgi;u32 timestamp =0 ;int err; -/* calculate the fifo get index for where to read data */ - fgi =FIELD_GET (RXFS_FGI_MASK , rxfs); err =m_can_fifo_read (cdev, fgi,M_CAN_FIFO_ID , &fifo_header,2 );if (err) goto out_fail;
@@ -554,6 +551,9 @@ static int m_can_do_rx_poll(struct net_device *dev, int quota)struct m_can_classdev *cdev =netdev_priv (dev);u32 pkts =0 ;u32 rxfs; +u32 rx_count; +u32 fgi; +int i;int err; rxfs =m_can_read (cdev,M_CAN_RXF0S );
@@ -562,14 +562,17 @@ static int m_can_do_rx_poll(struct net_device *dev, int quota)return 0 ; } -while ((rxfs &RXFS_FFL_MASK ) && (quota >0 )) { - err =m_can_read_fifo (dev, rxfs); + rx_count =FIELD_GET (RXFS_FFL_MASK , rxfs); + fgi =FIELD_GET (RXFS_FGI_MASK , rxfs); + +for (i =0 ; i < rx_count && quota >0 ; ++i) { + err =m_can_read_fifo (dev, fgi);if (err)return err; quota--; pkts++; - rxfs =m_can_read (cdev,M_CAN_RXF0S ); + fgi = (++fgi >= cdev->mcfg[MRAM_RXF0 ].num ?0 : fgi); }return pkts;
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 34/39 can: m_can: Batch acknowledge transmit events
In reply to Marc Kleine-BuddeFrom: Markus Schneider-Pargmann <[email protected]>
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.
--- drivers/net/can/m_can/m_can.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/net/can/m_can/m_can.c +9 -6
@@ -1023,7 +1023,9 @@ static int m_can_echo_tx_event(struct net_device *dev)u32 txe_count =0 ;u32 m_can_txefs;u32 fgi =0 ; +int ack_fgi =-1 ;int i =0 ; +int err =0 ;unsigned int msg_mark;struct m_can_classdev *cdev =netdev_priv (dev);
@@ -1038,28 +1040,29 @@ static int m_can_echo_tx_event(struct net_device *dev)/* Get and process all sent elements */ for (i =0 ; i < txe_count; i++) {u32 txe, timestamp =0 ; -int err;/* get message marker, timestamp */ err =m_can_txe_fifo_read (cdev, fgi,4 , &txe);if (err) {netdev_err (dev,"TXE FIFO read returned %d\n" , err); -return err; +break ; } msg_mark =FIELD_GET (TX_EVENT_MM_MASK , txe); timestamp =FIELD_GET (TX_EVENT_TXTS_MASK , txe) <<16 ; -/* ack txe element */ -m_can_write (cdev,M_CAN_TXEFA ,FIELD_PREP (TXEFA_EFAI_MASK , - fgi)); + ack_fgi = fgi; fgi = (++fgi >= cdev->mcfg[MRAM_TXE ].num ?0 : fgi);/* update stats */ m_can_tx_update_stats (cdev, msg_mark, timestamp); } -return 0 ; +if (ack_fgi !=-1 ) +m_can_write (cdev,M_CAN_TXEFA ,FIELD_PREP (TXEFA_EFAI_MASK , + ack_fgi)); + +return err; }static irqreturn_t m_can_isr (int irq,void *dev_id)
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 35/39 can: m_can: Batch acknowledge rx fifo
In reply to Marc Kleine-BuddeFrom: Markus Schneider-Pargmann <[email protected]>
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.
--- drivers/net/can/m_can/m_can.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/net/can/m_can/m_can.c +10 -5
@@ -530,9 +530,6 @@ static int m_can_read_fifo(struct net_device *dev, u32 fgi) } stats->rx_packets++; -/* acknowledge rx fifo 0 */ -m_can_write (cdev,M_CAN_RXF0A , fgi); - timestamp =FIELD_GET (RX_BUF_RXTS_MASK , fifo_header.dlc) <<16 ;m_can_receive_skb (cdev, skb, timestamp);
@@ -553,8 +550,9 @@ static int m_can_do_rx_poll(struct net_device *dev, int quota)u32 rxfs;u32 rx_count;u32 fgi; +int ack_fgi =-1 ;int i; -int err; +int err =0 ; rxfs =m_can_read (cdev,M_CAN_RXF0S );if (!(rxfs &RXFS_FFL_MASK )) {
@@ -568,13 +566,20 @@ static int m_can_do_rx_poll(struct net_device *dev, int quota)for (i =0 ; i < rx_count && quota >0 ; ++i) { err =m_can_read_fifo (dev, fgi);if (err) -return err; +break ; quota--; pkts++; + ack_fgi = fgi; fgi = (++fgi >= cdev->mcfg[MRAM_RXF0 ].num ?0 : fgi); } +if (ack_fgi !=-1 ) +m_can_write (cdev,M_CAN_RXF0A , ack_fgi); + +if (err) +return err; +return pkts; }
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 36/39 can: tcan4x5x: Remove invalid write in clear_interrupts
In reply to Marc Kleine-BuddeFrom: Markus Schneider-Pargmann <[email protected]>
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.
--- drivers/net/can/m_can/tcan4x5x-core.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/net/can/m_can/tcan4x5x-core.c +0 -5
@@ -204,11 +204,6 @@ static int tcan4x5x_clear_interrupts(struct m_can_classdev *cdev)if (ret)return ret; - ret =tcan4x5x_write_tcan_reg (cdev,TCAN4X5X_MCAN_INT_REG , -TCAN4X5X_ENABLE_MCAN_INT ); -if (ret) -return ret; - ret =tcan4x5x_write_tcan_reg (cdev,TCAN4X5X_INT_FLAGS ,TCAN4X5X_CLEAR_ALL_INT );if (ret)
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 37/39 can: tcan4x5x: Fix use of register error status mask
In reply to Marc Kleine-BuddeFrom: Markus Schneider-Pargmann <[email protected]>
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.
--- drivers/net/can/m_can/tcan4x5x-core.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/can/m_can/tcan4x5x-core.c +7 -7
@@ -10,7 +10,7 @@#define TCAN4X5X_DEV_ID1 0x04#define TCAN4X5X_REV 0x08#define TCAN4X5X_STATUS 0x0C -#define TCAN4X5X_ERROR_STATUS 0x10 +#define TCAN4X5X_ERROR_STATUS_MASK 0x10#define TCAN4X5X_CONTROL 0x14#define TCAN4X5X_CONFIG 0x800
@@ -204,12 +204,7 @@ static int tcan4x5x_clear_interrupts(struct m_can_classdev *cdev)if (ret)return ret; - ret =tcan4x5x_write_tcan_reg (cdev,TCAN4X5X_INT_FLAGS , -TCAN4X5X_CLEAR_ALL_INT ); -if (ret) -return ret; - -return tcan4x5x_write_tcan_reg (cdev,TCAN4X5X_ERROR_STATUS , +return tcan4x5x_write_tcan_reg (cdev,TCAN4X5X_INT_FLAGS ,TCAN4X5X_CLEAR_ALL_INT ); }
@@ -229,6 +224,11 @@ static int tcan4x5x_init(struct m_can_classdev *cdev)if (ret)return ret; + ret =tcan4x5x_write_tcan_reg (cdev,TCAN4X5X_ERROR_STATUS_MASK , +TCAN4X5X_CLEAR_ALL_INT ); +if (ret) +return ret; + ret =regmap_update_bits (tcan4x5x->regmap,TCAN4X5X_CONFIG ,TCAN4X5X_MODE_SEL_MASK ,TCAN4X5X_MODE_NORMAL );if (ret)
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 38/39 can: tcan4x5x: Fix register range of first two blocks
In reply to Marc Kleine-BuddeFrom: Markus Schneider-Pargmann <[email protected]>
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.
--- drivers/net/can/m_can/tcan4x5x-regmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/can/m_can/tcan4x5x-regmap.c +2 -2
@@ -91,8 +91,8 @@ static int tcan4x5x_regmap_read(void *context, }static const struct regmap_range tcan4x5x_reg_table_yes_range[] = { -regmap_reg_range (0x0000 ,0x002c ),/* Device ID and SPI Registers */ -regmap_reg_range (0x0800 ,0x083c ),/* Device configuration registers and Interrupt Flags*/ +regmap_reg_range (0x0000 ,0x0010 ),/* Device ID and SPI Registers */ +regmap_reg_range (0x0800 ,0x0830 ),/* Device configuration registers and Interrupt Flags*/ regmap_reg_range (0x1000 ,0x10fc ),/* M_CAN */ regmap_reg_range (0x8000 ,0x87fc ),/* MRAM */ };
Signature · 1 line
2.35.1
Marc Kleine-Budde
maintainerPATCH 39/39 can: tcan4x5x: Specify separate read/write ranges
In reply to Marc Kleine-BuddeFrom: Markus Schneider-Pargmann <[email protected]>
Specify exactly which registers are read/writeable in the chip. This is supposed to help detect any violations in the future.
--- drivers/net/can/m_can/tcan4x5x-regmap.c | 43 +++++++++++++++++++++---- 1 file changed, 37 insertions(+), 6 deletions(-)
drivers/net/can/m_can/tcan4x5x-regmap.c +37 -6
@@ -90,16 +90,47 @@ static int tcan4x5x_regmap_read(void *context,return 0 ; } -static const struct regmap_range tcan4x5x_reg_table_yes_range[] = { +static const struct regmap_range tcan4x5x_reg_table_wr_range[] = { +/* Device ID and SPI Registers */ +regmap_reg_range (0x000c ,0x0010 ), +/* Device configuration registers and Interrupt Flags*/ +regmap_reg_range (0x0800 ,0x080c ), +regmap_reg_range (0x0814 ,0x0814 ), +regmap_reg_range (0x0820 ,0x0820 ), +regmap_reg_range (0x0830 ,0x0830 ), +/* M_CAN */ +regmap_reg_range (0x100c ,0x102c ), +regmap_reg_range (0x1048 ,0x1048 ), +regmap_reg_range (0x1050 ,0x105c ), +regmap_reg_range (0x1080 ,0x1088 ), +regmap_reg_range (0x1090 ,0x1090 ), +regmap_reg_range (0x1098 ,0x10a0 ), +regmap_reg_range (0x10a8 ,0x10b0 ), +regmap_reg_range (0x10b8 ,0x10c0 ), +regmap_reg_range (0x10c8 ,0x10c8 ), +regmap_reg_range (0x10d0 ,0x10d4 ), +regmap_reg_range (0x10e0 ,0x10e4 ), +regmap_reg_range (0x10f0 ,0x10f0 ), +regmap_reg_range (0x10f8 ,0x10f8 ), +/* MRAM */ +regmap_reg_range (0x8000 ,0x87fc ), +}; + +static const struct regmap_range tcan4x5x_reg_table_rd_range[] = {regmap_reg_range (0x0000 ,0x0010 ),/* Device ID and SPI Registers */ regmap_reg_range (0x0800 ,0x0830 ),/* Device configuration registers and Interrupt Flags*/ regmap_reg_range (0x1000 ,0x10fc ),/* M_CAN */ regmap_reg_range (0x8000 ,0x87fc ),/* MRAM */ }; -static const struct regmap_access_table tcan4x5x_reg_table = { - .yes_ranges = tcan4x5x_reg_table_yes_range, - .n_yes_ranges =ARRAY_SIZE (tcan4x5x_reg_table_yes_range), +static const struct regmap_access_table tcan4x5x_reg_table_wr = { + .yes_ranges = tcan4x5x_reg_table_wr_range, + .n_yes_ranges =ARRAY_SIZE (tcan4x5x_reg_table_wr_range), +}; + +static const struct regmap_access_table tcan4x5x_reg_table_rd = { + .yes_ranges = tcan4x5x_reg_table_rd_range, + .n_yes_ranges =ARRAY_SIZE (tcan4x5x_reg_table_rd_range), };static const struct regmap_config tcan4x5x_regmap = {
@@ -107,8 +138,8 @@ static const struct regmap_config tcan4x5x_regmap = { .reg_stride = 4, .pad_bits = 8, .val_bits = 32, - .wr_table = &tcan4x5x_reg_table, - .rd_table = &tcan4x5x_reg_table, + .wr_table = &tcan4x5x_reg_table_wr, + .rd_table = &tcan4x5x_reg_table_rd, .max_register = TCAN4X5X_MAX_REGISTER, .cache_type = REGCACHE_NONE, .read_flag_mask = (__force unsigned long)
Signature · 1 line
2.35.1