can: m_can: Add driver for M_CAN hardware in NVIDIA devices
Subsystems (5)
RFC PATCH 1/1 can: m_can: Add driver for M_CAN hardware in NVIDIA devices
It's a M_TTCAN with some NVIDIA-specific glue logic and clocks. The existing m_can driver works with it after handling the glue logic.
The code is a combination of pieces from m_can_platform and NVIDIA's driver [1].
---
I ran into bugs with the error handling in NVIDIA's m_ttcan driver, so I switched to m_can which has been much better. I'm looking for feedback on whether I should ensure rebasing hasn't broken anything, write up DT documentation, and submit this patch for real. The driver works great, but I've got some questions about submitting it.
question: This has liberal copying of GPL code from NVIDIA's non-upstreamed m_ttcan driver. Is that OK?
corollary: I don't know what any of this glue logic does. I do know the device doesn't work without it. I can't find any documentation of what these addresses do.
question: There is some duplication between this and m_can_platform. It doesn't seem too bad to me, but is this the preferred way to do it or is there another alternative?
question: Do new DT bindings need to be in the YAML format, or is the .txt one OK?
drivers/net/can/m_can/Kconfig | 10 + drivers/net/can/m_can/Makefile | 1 + drivers/net/can/m_can/m_can_tegra.c | 362 ++++++++++++++++++++++++++++ 3 files changed, 373 insertions(+) create mode 100644 drivers/net/can/m_can/m_can_tegra.c
drivers/net/can/m_can/Kconfig +10 -0
@@ -22,6 +22,16 @@ config CAN_M_CAN_PLATFORM This support is for devices that have the Bosch M_CAN controller IP embedded into the device and the IP is IO Mapped to the processor. +config CAN_M_CAN_TEGRA + tristate "Bosch M_CAN support for io-mapped devices on NVIDIA Tegra" + depends on HAS_IOMEM + ---help--- + Say Y here if you want support for IO Mapped Bosch M_CAN controller, + with additional NVIDIA Tegra-specific glue logic. + This support is for Tegra devices that have the Bosch M_CAN/M_TTCAN + controller IP embedded into the device and the IP is IO Mapped to the + processor. + config CAN_M_CAN_TCAN4X5X depends on SPI select REGMAP_SPI
drivers/net/can/m_can/Makefile +1 -0
@@ -6,6 +6,7 @@ obj-$(CONFIG_CAN_M_CAN) += m_can.o obj-$(CONFIG_CAN_M_CAN_PCI) += m_can_pci.o obj-$(CONFIG_CAN_M_CAN_PLATFORM) += m_can_platform.o +obj-$(CONFIG_CAN_M_CAN_TEGRA) += m_can_tegra.o obj-$(CONFIG_CAN_M_CAN_TCAN4X5X) += tcan4x5x.o tcan4x5x-objs :=
drivers/net/can/m_can/m_can_tegra.c new file +362 -0
362 lines not on this page · raw message
Signature · 1 line
2.20.1
kernel test robot
build bot[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch]
Hi Brian,
[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on mkl-can-next/testing]
[also build test ERROR on v5.16-rc8 next-20220105]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Brian-Silverman/can-m_can-Add-driver-for-M_CAN-hardware-in-NVIDIA-devices/20220106-082838 base: https://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git testing config: i386-randconfig-a012-20220105 compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project ca7ffe09dc6e525109e3cd570cc5182ce568be13)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/3c5bcd8d6834eb3e2ac215c9aa35b662aca84aac
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Brian-Silverman/can-m_can-Add-driver-for-M_CAN-hardware-in-NVIDIA-devices/20220106-082838 git checkout 3c5bcd8d6834eb3e2ac215c9aa35b662aca84aac
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=i386 randconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=i386
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
>> drivers/net/can/m_can/Kconfig:29: syntax error
drivers/net/can/m_can/Kconfig:28: unknown statement "---help---" drivers/net/can/m_can/Kconfig:29:warning: ignoring unsupported character ',' drivers/net/can/m_can/Kconfig:29: unknown statement "Say" drivers/net/can/m_can/Kconfig:30:warning: ignoring unsupported character '.' drivers/net/can/m_can/Kconfig:30: unknown statement "with" drivers/net/can/m_can/Kconfig:31:warning: ignoring unsupported character '/' drivers/net/can/m_can/Kconfig:31: unknown statement "This" drivers/net/can/m_can/Kconfig:32: unknown statement "controller" drivers/net/can/m_can/Kconfig:33:warning: ignoring unsupported character '.' drivers/net/can/m_can/Kconfig:33: unknown statement "processor" make[2]: *** [scripts/kconfig/Makefile:77: oldconfig] Error 1 make[1]: *** [Makefile:619: oldconfig] Error 2
make: *** [Makefile:219: __sub-make] Error 2
make: Target 'oldconfig' not remade because of errors.
--
>> drivers/net/can/m_can/Kconfig:29: syntax error
drivers/net/can/m_can/Kconfig:28: unknown statement "---help---" drivers/net/can/m_can/Kconfig:29:warning: ignoring unsupported character ',' drivers/net/can/m_can/Kconfig:29: unknown statement "Say" drivers/net/can/m_can/Kconfig:30:warning: ignoring unsupported character '.' drivers/net/can/m_can/Kconfig:30: unknown statement "with" drivers/net/can/m_can/Kconfig:31:warning: ignoring unsupported character '/' drivers/net/can/m_can/Kconfig:31: unknown statement "This" drivers/net/can/m_can/Kconfig:32: unknown statement "controller" drivers/net/can/m_can/Kconfig:33:warning: ignoring unsupported character '.' drivers/net/can/m_can/Kconfig:33: unknown statement "processor" make[2]: *** [scripts/kconfig/Makefile:77: olddefconfig] Error 1 make[1]: *** [Makefile:619: olddefconfig] Error 2
make: *** [Makefile:219: __sub-make] Error 2
make: Target 'olddefconfig' not remade because of errors.
vim +29 drivers/net/can/m_can/Kconfig
9
10 config CAN_M_CAN_PCI
11 tristate "Generic PCI Bus based M_CAN driver"
12 depends on PCI
13 help
14 Say Y here if you want to support Bosch M_CAN controller connected
15 to the pci bus.
16
17 config CAN_M_CAN_PLATFORM
18 tristate "Bosch M_CAN support for io-mapped devices"
19 depends on HAS_IOMEM
20 help
21 Say Y here if you want support for IO Mapped Bosch M_CAN controller.
22 This support is for devices that have the Bosch M_CAN controller
23 IP embedded into the device and the IP is IO Mapped to the processor.
24
25 config CAN_M_CAN_TEGRA
26 tristate "Bosch M_CAN support for io-mapped devices on NVIDIA Tegra"
27 depends on HAS_IOMEM
28 ---help---
> 29 Say Y here if you want support for IO Mapped Bosch M_CAN controller,
30 with additional NVIDIA Tegra-specific glue logic.
31 This support is for Tegra devices that have the Bosch M_CAN/M_TTCAN
32 controller IP embedded into the device and the IP is IO Mapped to the
33 processor.
34
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build bot[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch]
Hi Brian,
[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on mkl-can-next/testing]
[also build test ERROR on v5.16-rc8 next-20220105]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Brian-Silverman/can-m_can-Add-driver-for-M_CAN-hardware-in-NVIDIA-devices/20220106-082838 base: https://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git testing config: x86_64-allyesconfig compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 reproduce (this is a W=1 build): # https://github.com/0day-ci/linux/commit/3c5bcd8d6834eb3e2ac215c9aa35b662aca84aac git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Brian-Silverman/can-m_can-Add-driver-for-M_CAN-hardware-in-NVIDIA-devices/20220106-082838 git checkout 3c5bcd8d6834eb3e2ac215c9aa35b662aca84aac make W=1 ARCH=x86_64 allyesconfig make W=1 ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
>> drivers/net/can/m_can/Kconfig:29: syntax error
drivers/net/can/m_can/Kconfig:28: unknown statement "---help---" drivers/net/can/m_can/Kconfig:29:warning: ignoring unsupported character ',' drivers/net/can/m_can/Kconfig:29: unknown statement "Say" drivers/net/can/m_can/Kconfig:30:warning: ignoring unsupported character '.' drivers/net/can/m_can/Kconfig:30: unknown statement "with" drivers/net/can/m_can/Kconfig:31:warning: ignoring unsupported character '/' drivers/net/can/m_can/Kconfig:31: unknown statement "This" drivers/net/can/m_can/Kconfig:32: unknown statement "controller" drivers/net/can/m_can/Kconfig:33:warning: ignoring unsupported character '.' drivers/net/can/m_can/Kconfig:33: unknown statement "processor" make[2]: *** [scripts/kconfig/Makefile:77: allyesconfig] Error 1 make[1]: *** [Makefile:619: allyesconfig] Error 2
make: *** [Makefile:219: __sub-make] Error 2
make: Target 'allyesconfig' not remade because of errors.
--
>> drivers/net/can/m_can/Kconfig:29: syntax error
drivers/net/can/m_can/Kconfig:28: unknown statement "---help---" drivers/net/can/m_can/Kconfig:29:warning: ignoring unsupported character ',' drivers/net/can/m_can/Kconfig:29: unknown statement "Say" drivers/net/can/m_can/Kconfig:30:warning: ignoring unsupported character '.' drivers/net/can/m_can/Kconfig:30: unknown statement "with" drivers/net/can/m_can/Kconfig:31:warning: ignoring unsupported character '/' drivers/net/can/m_can/Kconfig:31: unknown statement "This" drivers/net/can/m_can/Kconfig:32: unknown statement "controller" drivers/net/can/m_can/Kconfig:33:warning: ignoring unsupported character '.' drivers/net/can/m_can/Kconfig:33: unknown statement "processor" make[2]: *** [scripts/kconfig/Makefile:77: oldconfig] Error 1 make[1]: *** [Makefile:619: oldconfig] Error 2
make: *** [Makefile:219: __sub-make] Error 2
make: Target 'oldconfig' not remade because of errors.
--
>> drivers/net/can/m_can/Kconfig:29: syntax error
drivers/net/can/m_can/Kconfig:28: unknown statement "---help---" drivers/net/can/m_can/Kconfig:29:warning: ignoring unsupported character ',' drivers/net/can/m_can/Kconfig:29: unknown statement "Say" drivers/net/can/m_can/Kconfig:30:warning: ignoring unsupported character '.' drivers/net/can/m_can/Kconfig:30: unknown statement "with" drivers/net/can/m_can/Kconfig:31:warning: ignoring unsupported character '/' drivers/net/can/m_can/Kconfig:31: unknown statement "This" drivers/net/can/m_can/Kconfig:32: unknown statement "controller" drivers/net/can/m_can/Kconfig:33:warning: ignoring unsupported character '.' drivers/net/can/m_can/Kconfig:33: unknown statement "processor" make[2]: *** [scripts/kconfig/Makefile:77: olddefconfig] Error 1 make[1]: *** [Makefile:619: olddefconfig] Error 2
make: *** [Makefile:219: __sub-make] Error 2
make: Target 'olddefconfig' not remade because of errors.
vim +29 drivers/net/can/m_can/Kconfig
9
10 config CAN_M_CAN_PCI
11 tristate "Generic PCI Bus based M_CAN driver"
12 depends on PCI
13 help
14 Say Y here if you want to support Bosch M_CAN controller connected
15 to the pci bus.
16
17 config CAN_M_CAN_PLATFORM
18 tristate "Bosch M_CAN support for io-mapped devices"
19 depends on HAS_IOMEM
20 help
21 Say Y here if you want support for IO Mapped Bosch M_CAN controller.
22 This support is for devices that have the Bosch M_CAN controller
23 IP embedded into the device and the IP is IO Mapped to the processor.
24
25 config CAN_M_CAN_TEGRA
26 tristate "Bosch M_CAN support for io-mapped devices on NVIDIA Tegra"
27 depends on HAS_IOMEM
28 ---help---
> 29 Say Y here if you want support for IO Mapped Bosch M_CAN controller,
30 with additional NVIDIA Tegra-specific glue logic.
31 This support is for Tegra devices that have the Bosch M_CAN/M_TTCAN
32 controller IP embedded into the device and the IP is IO Mapped to the
33 processor.
34
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Marc Kleine-Budde
maintainerQuoted 9 lines · Brian Silverman
It's a
M_TTCANwith some NVIDIA-specific glue logic and clocks. The existingm_candriver works with it after handling the glue logic.The code is a combination of pieces from
m_can_platformand NVIDIA's driver [1].Signed-off-by Brian Silverman <[email protected]>
Thanks for your patch.
Quoted 9 lines
---
I ran into bugs with the error handling in NVIDIA'sm_ttcandriver, so I switched tom_canwhich has been much better. I'm looking for feedback on whether I should ensure rebasing hasn't broken anything, write up DT documentation, and submit this patch for real. The driver works great, but I've got some questions about submitting it.question: This has liberal copying of GPL code from NVIDIA's non-upstreamed
m_ttcandriver. Is that OK?
The header in the driver says it's GPLv2:
So it's OK. You should copy the original copyright notice to your glue driver, though.
Quoted 3 lines
corollary: I don't know what any of this glue logic does. I do know the device doesn't work without it. I can't find any documentation of what these addresses do.
hmmm ok
Quoted 3 lines
question: There is some duplication between this and
m_can_platform. It doesn't seem too bad to me, but is this the preferred way to do it or is there another alternative?
You might merge this driver to the generic platform driver.
Quoted 2 lines
question: Do new DT bindings need to be in the YAML format, or is the .txt one OK?
YAML
Please fix the checkpatch warning found by:
| ./scripts/checkpatch.pl --file drivers/net/can/m_can/m_can_tegra.c
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 |
Quoted 27 lines · Brian Silverman
It's a
M_TTCANwith some NVIDIA-specific glue logic and clocks. The existingm_candriver works with it after handling the glue logic.The code is a combination of pieces from
m_can_platformand NVIDIA's driver [1].Signed-off-by Brian Silverman <[email protected]>---
I ran into bugs with the error handling in NVIDIA'sm_ttcandriver, so I switched tom_canwhich has been much better. I'm looking for feedback on whether I should ensure rebasing hasn't broken anything, write up DT documentation, and submit this patch for real. The driver works great, but I've got some questions about submitting it.question: This has liberal copying of GPL code from NVIDIA's non-upstreamed
m_ttcandriver. Is that OK?corollary: I don't know what any of this glue logic does. I do know the device doesn't work without it. I can't find any documentation of what these addresses do.
question: There is some duplication between this and
m_can_platform. It doesn't seem too bad to me, but is this the preferred way to do it or is there another alternative?
Quoted 8 lines
question: Do new DT bindings need to be in the YAML format, or is the .txt one OK?
drivers/net/can/m_can/Kconfig | 10 + drivers/net/can/m_can/Makefile | 1 + drivers/net/can/m_can/m_can_tegra.c | 362 ++++++++++++++++++++++++++++ 3 files changed, 373 insertions(+) create mode 100644 drivers/net/can/m_can/m_can_tegra.c
Sorry for the late reply, I completely missed this. I think along with the DT bindings it'd be great if you could provide DT updates for the platform that you tested this on so we can get that upstream as well.
I don't know much about CAN so I can't comment on those pieces, so just a few thoughts on the integration bits.
Quoted 1 line
drivers/net/can/m_can/m_can_tegra.c +0
-0
[...]
Quoted 2 lines
drivers/net/can/m_can/m_can_tegra.c +2
-0+static int m_can_tegra_probe (struct platform_device *pdev) +{
[...]
Quoted 28 lines
drivers/net/can/m_can/m_can_tegra.c +28
-0+ ret =clk_set_parent (can_clk, pclk); +if (ret) { + goto probe_fail; + } + + ret =fwnode_property_read_u32 (dev_fwnode (&pdev->dev),"can-clk-rate" , &rate); +if (ret) { + goto probe_fail; + } + + new_rate =clk_round_rate (can_clk, rate); +if (!new_rate) +dev_warn (&pdev->dev,"incorrect CAN clock rate\n" ); + + ret =clk_set_rate (can_clk, new_rate >0 ? new_rate : rate); +if (ret) { + goto probe_fail; + } + + ret =clk_set_rate (host_clk, new_rate >0 ? new_rate : rate); +if (ret) { + goto probe_fail; + } + +if (core_clk) { + ret =fwnode_property_read_u32 (dev_fwnode (&pdev->dev),"core-clk-rate" , &rate); +if (ret) { + goto probe_fail;
drivers/net/can/m_can/m_can_tegra.c line 187
Quoted 10 lines
drivers/net/can/m_can/m_can_tegra.c +10
-0+ } + new_rate =clk_round_rate (core_clk, rate); +if (!new_rate) +dev_warn (&pdev->dev,"incorrect CAN_CORE clock rate\n" ); + + ret =clk_set_rate (core_clk, new_rate >0 ? new_rate : rate); +if (ret) { + goto probe_fail; + } + }
Can all of this clock setup not be simplified by using the standard assigned-clocks, assigned-clock-parent and assigned-clock-rates DT properties?
drivers/net/can/m_can/m_can_tegra.c line 200
Quoted 13 lines
drivers/net/can/m_can/m_can_tegra.c +13
-0+ + res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"m_can" ); + addr =devm_ioremap_resource (&pdev->dev, res); +if (IS_ERR (addr)) { + ret =PTR_ERR (addr); + goto probe_fail; + } + + irq =platform_get_irq_byname (pdev,"int0" ); +if (irq <0 ) { + ret = -ENODEV ; + goto probe_fail; + }
If there's only one of these, it doesn't make much sense to name them. But perhaps this can be discussed when reviewing the DT bindings.
[...]
drivers/net/can/m_can/m_can_tegra.c line 343
Quoted 2 lines
drivers/net/can/m_can/m_can_tegra.c +2
-0+static const struct of_device_id m_can_of_table[] = { + { .compatible ="nvidia,tegra194-m_can" , .data =NULL },
We typically name the compatible string after the IP block name. The TRM references this as simply "CAN", so I think "nvidia,tegra194-can" would be more in line with what we use for existing Tegra hardware.
Thierry
Marc Kleine-Budde
maintainerQuoted 31 lines · Thierry Reding
Quoted 30 lines · Brian Silverman
It's a
M_TTCANwith some NVIDIA-specific glue logic and clocks. The existingm_candriver works with it after handling the glue logic.The code is a combination of pieces from
m_can_platformand NVIDIA's driver [1].Signed-off-by Brian Silverman <[email protected]>---
I ran into bugs with the error handling in NVIDIA'sm_ttcandriver, so I switched tom_canwhich has been much better. I'm looking for feedback on whether I should ensure rebasing hasn't broken anything, write up DT documentation, and submit this patch for real. The driver works great, but I've got some questions about submitting it.question: This has liberal copying of GPL code from NVIDIA's non-upstreamed
m_ttcandriver. Is that OK?corollary: I don't know what any of this glue logic does. I do know the device doesn't work without it. I can't find any documentation of what these addresses do.
question: There is some duplication between this and
m_can_platform. It doesn't seem too bad to me, but is this the preferred way to do it or is there another alternative?question: Do new DT bindings need to be in the YAML format, or is the .txt one OK?
Quoted 7 lines
Quoted 5 lines
drivers/net/can/m_can/Kconfig | 10 + drivers/net/can/m_can/Makefile | 1 + drivers/net/can/m_can/m_can_tegra.c | 362 ++++++++++++++++++++++++++++ 3 files changed, 373 insertions(+) create mode 100644 drivers/net/can/m_can/m_can_tegra.cSorry for the late reply, I completely missed this.
Brian Silverman left the company bluerivertech, I think there'll be no progress on the tegra glue code. :/
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 |