All of lore.kernel.org
 help / color / mirror / Atom feed
* mcp251xfd on RPi 5.4 downstream
@ 2020-10-22  3:10 Drew Fustini
  2020-10-22  6:00 ` Drew Fustini
  2020-11-20 12:32 ` Marc Kleine-Budde
  0 siblings, 2 replies; 54+ messages in thread
From: Drew Fustini @ 2020-10-22  3:10 UTC (permalink / raw)
  To: linux-can, Marc Kleine-Budde; +Cc: Josh S

Hi Marc, thanks for working on mcp251xfd driver that has been pulled into 5.10.

I would like to use it with the official rpi-5.4.y branch [1] which
currently ships on their Raspberry Pi OS image.  The target board is a
Raspberry Pi 4 in 32-bit mode which uses bcm2711_defconfig [2]
according to their instructions [3].

I copied mcp251xfd from 5.10 and got this error when compiling:
===================================================
  AR      drivers/net/can/spi/mcp251xfd/built-in.a
  CC [M]  drivers/net/can/spi/mcp251xfd/mcp251xfd-core.o
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c: In function
‘mcp251xfd_tx_ring_init_tx_obj’:
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c:314:23: error: request
for member ‘value’ in something not a structure or union
  xfer->cs_change_delay.value = 0;
                       ^
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c:315:23: error: request
for member ‘unit’ in something not a structure or union
  xfer->cs_change_delay.unit = SPI_DELAY_UNIT_NSECS;
                       ^
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c: In function ‘mcp251xfd_probe’:
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c:2862:2: error: implicit
declaration of function ‘can_rx_offload_add_manual’
[-Werror=implicit-function-declaration]
  err = can_rx_offload_add_manual(ndev, &priv->offload,
  ^
cc1: some warnings being treated as errors
make[5]: *** [scripts/Makefile.build:266:
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.o] Error 1
make[4]: *** [scripts/Makefile.build:500: drivers/net/can/spi/mcp251xfd] Error 2
make[3]: *** [scripts/Makefile.build:500: drivers/net/can/spi] Error 2
make[2]: *** [scripts/Makefile.build:500: drivers/net/can] Error 2
make[1]: *** [scripts/Makefile.build:500: drivers/net] Error 2
make: *** [Makefile:1732: drivers] Error 2
===================================================

I believe this is a result of 329f0dac4cad ("spi: make
`cs_change_delay` the first user of the `spi_delay` logic") where
integer values `cs_change_delay` and `cs_change_delay_unit` are
replaced with `struct spi_delay`.

I thought I would ask if you have any advice before I start making
incremental changes to get it to compile under 5.4.

thank you,
drew

[1] https://github.com/raspberrypi/linux/blob/rpi-5.4.y/
[2] https://github.com/raspberrypi/linux/blob/rpi-5.4.y/arch/arm/configs/bcm2711_defconfig
[3] https://www.raspberrypi.org/documentation/linux/kernel/building.md

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-22  3:10 mcp251xfd on RPi 5.4 downstream Drew Fustini
@ 2020-10-22  6:00 ` Drew Fustini
  2020-10-22  6:33   ` Marc Kleine-Budde
  2020-11-20 12:32 ` Marc Kleine-Budde
  1 sibling, 1 reply; 54+ messages in thread
From: Drew Fustini @ 2020-10-22  6:00 UTC (permalink / raw)
  To: linux-can, Marc Kleine-Budde; +Cc: Josh S

On Wed, Oct 21, 2020 at 10:10 PM Drew Fustini <drew@beagleboard.org> wrote:
>
> Hi Marc, thanks for working on mcp251xfd driver that has been pulled into 5.10.
>
> I would like to use it with the official rpi-5.4.y branch [1] which
> currently ships on their Raspberry Pi OS image.  The target board is a
> Raspberry Pi 4 in 32-bit mode which uses bcm2711_defconfig [2]
> according to their instructions [3].
>
> I copied mcp251xfd from 5.10 and got this error when compiling:
> ===================================================
>   AR      drivers/net/can/spi/mcp251xfd/built-in.a
>   CC [M]  drivers/net/can/spi/mcp251xfd/mcp251xfd-core.o
> drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c: In function
> ‘mcp251xfd_tx_ring_init_tx_obj’:
> drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c:314:23: error: request
> for member ‘value’ in something not a structure or union
>   xfer->cs_change_delay.value = 0;
>                        ^
> drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c:315:23: error: request
> for member ‘unit’ in something not a structure or union
>   xfer->cs_change_delay.unit = SPI_DELAY_UNIT_NSECS;
>                        ^
> drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c: In function ‘mcp251xfd_probe’:
> drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c:2862:2: error: implicit
> declaration of function ‘can_rx_offload_add_manual’
> [-Werror=implicit-function-declaration]
>   err = can_rx_offload_add_manual(ndev, &priv->offload,
>   ^
> cc1: some warnings being treated as errors
> make[5]: *** [scripts/Makefile.build:266:
> drivers/net/can/spi/mcp251xfd/mcp251xfd-core.o] Error 1
> make[4]: *** [scripts/Makefile.build:500: drivers/net/can/spi/mcp251xfd] Error 2
> make[3]: *** [scripts/Makefile.build:500: drivers/net/can/spi] Error 2
> make[2]: *** [scripts/Makefile.build:500: drivers/net/can] Error 2
> make[1]: *** [scripts/Makefile.build:500: drivers/net] Error 2
> make: *** [Makefile:1732: drivers] Error 2
> ===================================================
>
> I believe this is a result of 329f0dac4cad ("spi: make
> `cs_change_delay` the first user of the `spi_delay` logic") where
> integer values `cs_change_delay` and `cs_change_delay_unit` are
> replaced with `struct spi_delay`.
>
> I thought I would ask if you have any advice before I start making
> incremental changes to get it to compile under 5.4.
>
> thank you,
> drew
>
> [1] https://github.com/raspberrypi/linux/blob/rpi-5.4.y/
> [2] https://github.com/raspberrypi/linux/blob/rpi-5.4.y/arch/arm/configs/bcm2711_defconfig
> [3] https://www.raspberrypi.org/documentation/linux/kernel/building.md

It appears it was simpler to get it to compile than I expected.

cs_change_delay.unit becomes cs_change_delay_unit,  and
cs_change_delay.value becomes cs_change_delay.

The other issue was 728fc9ff73d3 ("can: rx-offload:
can_rx_offload_add_manual(): add new initialization function") which
was simply solved by adding can_rx_offload_add_manual() to:
include/linux/can/rx-offload.h
drivers/net/can/rx-offload.c

The driver builds ok:

filename:
/home/pdp7/dev/rpi/linux/./drivers/net/can/spi/mcp251xfd/mcp251xfd.ko
license:        GPL v2
description:    Microchip MCP251xFD Family CAN controller driver
author:         Marc Kleine-Budde <mkl@pengutronix.de>
srcversion:     336E42AD62992352D5E583E
alias:          spi:mcp251xfd
alias:          spi:mcp2518fd
alias:          spi:mcp2517fd
alias:          of:N*T*Cmicrochip,mcp251xfdC*
alias:          of:N*T*Cmicrochip,mcp251xfd
alias:          of:N*T*Cmicrochip,mcp2518fdC*
alias:          of:N*T*Cmicrochip,mcp2518fd
alias:          of:N*T*Cmicrochip,mcp2517fdC*
alias:          of:N*T*Cmicrochip,mcp2517fd
depends:        can-dev
intree:         Y
name:           mcp251xfd
vermagic:       5.4.72-v7l+ SMP mod_unload modversions ARMv7 p2v8

thanks,
drew

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-22  6:00 ` Drew Fustini
@ 2020-10-22  6:33   ` Marc Kleine-Budde
  2020-10-22 18:42     ` Drew Fustini
  0 siblings, 1 reply; 54+ messages in thread
From: Marc Kleine-Budde @ 2020-10-22  6:33 UTC (permalink / raw)
  To: Drew Fustini, linux-can; +Cc: Josh S


[-- Attachment #1.1: Type: text/plain, Size: 1110 bytes --]

On 10/22/20 8:00 AM, Drew Fustini wrote:
> It appears it was simpler to get it to compile than I expected.

\o/

> cs_change_delay.unit becomes cs_change_delay_unit,  and
> cs_change_delay.value becomes cs_change_delay.
> 
> The other issue was 728fc9ff73d3 ("can: rx-offload:
> can_rx_offload_add_manual(): add new initialization function") which
> was simply solved by adding can_rx_offload_add_manual() to:
> include/linux/can/rx-offload.h
> drivers/net/can/rx-offload.c
> 
> The driver builds ok:

With your help :) I backported current linus/master to the rpi-5.4:

https://github.com/marckleinebudde/linux/tree/v5.4-rpi/mcp251xfd-20201022-54

Can you test that?

Do you know the process to get that into the rpi kernel? Send a pull request on
github?

regards,
Marc

BTW: What's your current timezone?

-- 
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 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-22  6:33   ` Marc Kleine-Budde
@ 2020-10-22 18:42     ` Drew Fustini
  2020-10-25  4:30       ` Drew Fustini
  0 siblings, 1 reply; 54+ messages in thread
From: Drew Fustini @ 2020-10-22 18:42 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: linux-can, Josh S

On Thu, Oct 22, 2020 at 1:33 AM Marc Kleine-Budde <mkl@pengutronix.de> wrote:
>
> On 10/22/20 8:00 AM, Drew Fustini wrote:
> > It appears it was simpler to get it to compile than I expected.
>
> \o/
>
> > cs_change_delay.unit becomes cs_change_delay_unit,  and
> > cs_change_delay.value becomes cs_change_delay.
> >
> > The other issue was 728fc9ff73d3 ("can: rx-offload:
> > can_rx_offload_add_manual(): add new initialization function") which
> > was simply solved by adding can_rx_offload_add_manual() to:
> > include/linux/can/rx-offload.h
> > drivers/net/can/rx-offload.c
> >
> > The driver builds ok:
>
> With your help :) I backported current linus/master to the rpi-5.4:
>
> https://github.com/marckleinebudde/linux/tree/v5.4-rpi/mcp251xfd-20201022-54
>
> Can you test that?

Thanks, will do.   I am currently trying to finish up my ELC-E talk
prep :) but will get back to you with the results of testing later.

> Do you know the process to get that into the rpi kernel? Send a pull request on
> github?

Yes, the take pull requests on their git repo for their downstream branches.

>
> regards,
> Marc
>
> BTW: What's your current timezone?

currently in US CDT (UTC-5) until the end of October then back in
CEST.  However, I'll be up early next week for ELC-E :)

thanks,
drew

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-22 18:42     ` Drew Fustini
@ 2020-10-25  4:30       ` Drew Fustini
  2020-10-25  8:49         ` Oliver Hartkopp
  0 siblings, 1 reply; 54+ messages in thread
From: Drew Fustini @ 2020-10-25  4:30 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: linux-can, Josh S

On Thu, Oct 22, 2020 at 1:42 PM Drew Fustini <drew@beagleboard.org> wrote:
>
> On Thu, Oct 22, 2020 at 1:33 AM Marc Kleine-Budde <mkl@pengutronix.de> wrote:
> >
> > On 10/22/20 8:00 AM, Drew Fustini wrote:
> > > It appears it was simpler to get it to compile than I expected.
> >
> > \o/
> >
> > > cs_change_delay.unit becomes cs_change_delay_unit,  and
> > > cs_change_delay.value becomes cs_change_delay.
> > >
> > > The other issue was 728fc9ff73d3 ("can: rx-offload:
> > > can_rx_offload_add_manual(): add new initialization function") which
> > > was simply solved by adding can_rx_offload_add_manual() to:
> > > include/linux/can/rx-offload.h
> > > drivers/net/can/rx-offload.c
> > >
> > > The driver builds ok:
> >
> > With your help :) I backported current linus/master to the rpi-5.4:
> >
> > https://github.com/marckleinebudde/linux/tree/v5.4-rpi/mcp251xfd-20201022-54
> >
> > Can you test that?
>
> Thanks, will do.   I am currently trying to finish up my ELC-E talk
> prep :) but will get back to you with the results of testing later.

I noticed up doing a modprobe that there are several Unknown symbol errors.

Any ideas?

[  358.686691] mcp251xfd: Unknown symbol can_rx_offload_del (err -2)
[  358.686744] mcp251xfd: Unknown symbol can_put_echo_skb (err -2)
[  358.686796] mcp251xfd: Unknown symbol can_len2dlc (err -2)
[  358.686844] mcp251xfd: Unknown symbol alloc_canfd_skb (err -2)
[  358.686942] mcp251xfd: Unknown symbol open_candev (err -2)
[  358.687042] mcp251xfd: Unknown symbol alloc_can_skb (err -2)
[  358.687093] mcp251xfd: Unknown symbol unregister_candev (err -2)
[  358.687139] mcp251xfd: Unknown symbol can_change_state (err -2)
[  358.687183] mcp251xfd: Unknown symbol can_change_mtu (err -2)
[  358.687227] mcp251xfd: Unknown symbol can_rx_offload_add_manual (err -2)
[  358.687294] mcp251xfd: Unknown symbol free_candev (err -2)
[  358.687345] mcp251xfd: Unknown symbol alloc_candev_mqs (err -2)
[  358.687416] mcp251xfd: Unknown symbol close_candev (err -2)
[  358.687475] mcp251xfd: Unknown symbol can_bus_off (err -2)
[  358.687519] mcp251xfd: Unknown symbol can_rx_offload_enable (err -2)
[  358.687569] mcp251xfd: Unknown symbol can_rx_offload_get_echo_skb (err -2)
[  358.687656] mcp251xfd: Unknown symbol can_dlc2len (err -2)
[  358.687710] mcp251xfd: Unknown symbol alloc_can_err_skb (err -2)
[  358.687773] mcp251xfd: Unknown symbol can_rx_offload_queue_sorted (err -2)
[  358.687819] mcp251xfd: Unknown symbol register_candev (err -2)
[  369.092608] CAN device driver interface

root@raspberrypi:~# modinfo mcp251xfd
filename:
/lib/modules/5.4.72-v7l+/kernel/drivers/net/can/spi/mcp251xfd/mcp251xfd.ko
license:        GPL v2
description:    Microchip MCP251xFD Family CAN controller driver
author:         Marc Kleine-Budde <mkl@pengutronix.de>
srcversion:     1E05EEB5939E9AB22BA2E1B
alias:          spi:mcp251xfd
alias:          spi:mcp2518fd
alias:          spi:mcp2517fd
alias:          of:N*T*Cmicrochip,mcp251xfdC*
alias:          of:N*T*Cmicrochip,mcp251xfd
alias:          of:N*T*Cmicrochip,mcp2518fdC*
alias:          of:N*T*Cmicrochip,mcp2518fd
alias:          of:N*T*Cmicrochip,mcp2517fdC*
alias:          of:N*T*Cmicrochip,mcp2517fd
depends:        can-dev
intree:         Y
name:           mcp251xfd
vermagic:       5.4.72-v7l+ SMP mod_unload modversions ARMv7 p2v8

root@raspberrypi:~# lsmod |grep mcp
mcp251xfd              36864  0
can_dev                28672  1 mcp251xfd


Thanks,
Drew

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-25  4:30       ` Drew Fustini
@ 2020-10-25  8:49         ` Oliver Hartkopp
  2020-10-25 10:58           ` Marc Kleine-Budde
  0 siblings, 1 reply; 54+ messages in thread
From: Oliver Hartkopp @ 2020-10-25  8:49 UTC (permalink / raw)
  To: Drew Fustini, Marc Kleine-Budde; +Cc: linux-can, Josh S



On 25.10.20 05:30, Drew Fustini wrote:
> On Thu, Oct 22, 2020 at 1:42 PM Drew Fustini <drew@beagleboard.org> wrote:
>>
>> On Thu, Oct 22, 2020 at 1:33 AM Marc Kleine-Budde <mkl@pengutronix.de> wrote:
>>>
>>> On 10/22/20 8:00 AM, Drew Fustini wrote:
>>>> It appears it was simpler to get it to compile than I expected.
>>>
>>> \o/
>>>
>>>> cs_change_delay.unit becomes cs_change_delay_unit,  and
>>>> cs_change_delay.value becomes cs_change_delay.
>>>>
>>>> The other issue was 728fc9ff73d3 ("can: rx-offload:
>>>> can_rx_offload_add_manual(): add new initialization function") which
>>>> was simply solved by adding can_rx_offload_add_manual() to:
>>>> include/linux/can/rx-offload.h
>>>> drivers/net/can/rx-offload.c
>>>>
>>>> The driver builds ok:
>>>
>>> With your help :) I backported current linus/master to the rpi-5.4:
>>>
>>> https://github.com/marckleinebudde/linux/tree/v5.4-rpi/mcp251xfd-20201022-54
>>>
>>> Can you test that?
>>
>> Thanks, will do.   I am currently trying to finish up my ELC-E talk
>> prep :) but will get back to you with the results of testing later.
> 
> I noticed up doing a modprobe that there are several Unknown symbol errors.
> 
> Any ideas?
> 
> [  358.686691] mcp251xfd: Unknown symbol can_rx_offload_del (err -2)
> [  358.686744] mcp251xfd: Unknown symbol can_put_echo_skb (err -2)
> [  358.686796] mcp251xfd: Unknown symbol can_len2dlc (err -2)
> [  358.686844] mcp251xfd: Unknown symbol alloc_canfd_skb (err -2)
> [  358.686942] mcp251xfd: Unknown symbol open_candev (err -2)
> [  358.687042] mcp251xfd: Unknown symbol alloc_can_skb (err -2)
> [  358.687093] mcp251xfd: Unknown symbol unregister_candev (err -2)
> [  358.687139] mcp251xfd: Unknown symbol can_change_state (err -2)
> [  358.687183] mcp251xfd: Unknown symbol can_change_mtu (err -2)
> [  358.687227] mcp251xfd: Unknown symbol can_rx_offload_add_manual (err -2)
> [  358.687294] mcp251xfd: Unknown symbol free_candev (err -2)
> [  358.687345] mcp251xfd: Unknown symbol alloc_candev_mqs (err -2)
> [  358.687416] mcp251xfd: Unknown symbol close_candev (err -2)
> [  358.687475] mcp251xfd: Unknown symbol can_bus_off (err -2)
> [  358.687519] mcp251xfd: Unknown symbol can_rx_offload_enable (err -2)
> [  358.687569] mcp251xfd: Unknown symbol can_rx_offload_get_echo_skb (err -2)
> [  358.687656] mcp251xfd: Unknown symbol can_dlc2len (err -2)
> [  358.687710] mcp251xfd: Unknown symbol alloc_can_err_skb (err -2)
> [  358.687773] mcp251xfd: Unknown symbol can_rx_offload_queue_sorted (err -2)
> [  358.687819] mcp251xfd: Unknown symbol register_candev (err -2)
> [  369.092608] CAN device driver interface

The can-dev module has been loaded *after* mcp251xfd.

Don't know why autoloading did not work on your machine but doing a 
'modprobe can-dev' before loading the MCP driver should do it for a test.

Best,
Oliver

> 
> root@raspberrypi:~# modinfo mcp251xfd
> filename:
> /lib/modules/5.4.72-v7l+/kernel/drivers/net/can/spi/mcp251xfd/mcp251xfd.ko
> license:        GPL v2
> description:    Microchip MCP251xFD Family CAN controller driver
> author:         Marc Kleine-Budde <mkl@pengutronix.de>
> srcversion:     1E05EEB5939E9AB22BA2E1B
> alias:          spi:mcp251xfd
> alias:          spi:mcp2518fd
> alias:          spi:mcp2517fd
> alias:          of:N*T*Cmicrochip,mcp251xfdC*
> alias:          of:N*T*Cmicrochip,mcp251xfd
> alias:          of:N*T*Cmicrochip,mcp2518fdC*
> alias:          of:N*T*Cmicrochip,mcp2518fd
> alias:          of:N*T*Cmicrochip,mcp2517fdC*
> alias:          of:N*T*Cmicrochip,mcp2517fd
> depends:        can-dev
> intree:         Y
> name:           mcp251xfd
> vermagic:       5.4.72-v7l+ SMP mod_unload modversions ARMv7 p2v8
> 
> root@raspberrypi:~# lsmod |grep mcp
> mcp251xfd              36864  0
> can_dev                28672  1 mcp251xfd
> 
> 
> Thanks,
> Drew
> 

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-25  8:49         ` Oliver Hartkopp
@ 2020-10-25 10:58           ` Marc Kleine-Budde
  2020-10-25 17:43             ` Patrick Menschel
  0 siblings, 1 reply; 54+ messages in thread
From: Marc Kleine-Budde @ 2020-10-25 10:58 UTC (permalink / raw)
  To: Oliver Hartkopp; +Cc: Drew Fustini, linux-can, Josh S

On Sun, Oct 25, 2020 at 09:49:43AM +0100, Oliver Hartkopp wrote:
> > > Thanks, will do.   I am currently trying to finish up my ELC-E talk
> > > prep :) but will get back to you with the results of testing later.
> > 
> > I noticed up doing a modprobe that there are several Unknown symbol errors.
> > 
> > Any ideas?
> > 
> > [  358.686691] mcp251xfd: Unknown symbol can_rx_offload_del (err -2)
> > [  358.686744] mcp251xfd: Unknown symbol can_put_echo_skb (err -2)
> > [  358.686796] mcp251xfd: Unknown symbol can_len2dlc (err -2)
> > [  358.686844] mcp251xfd: Unknown symbol alloc_canfd_skb (err -2)
> > [  358.686942] mcp251xfd: Unknown symbol open_candev (err -2)
> > [  358.687042] mcp251xfd: Unknown symbol alloc_can_skb (err -2)
> > [  358.687093] mcp251xfd: Unknown symbol unregister_candev (err -2)
> > [  358.687139] mcp251xfd: Unknown symbol can_change_state (err -2)
> > [  358.687183] mcp251xfd: Unknown symbol can_change_mtu (err -2)
> > [  358.687227] mcp251xfd: Unknown symbol can_rx_offload_add_manual (err -2)
> > [  358.687294] mcp251xfd: Unknown symbol free_candev (err -2)
> > [  358.687345] mcp251xfd: Unknown symbol alloc_candev_mqs (err -2)
> > [  358.687416] mcp251xfd: Unknown symbol close_candev (err -2)
> > [  358.687475] mcp251xfd: Unknown symbol can_bus_off (err -2)
> > [  358.687519] mcp251xfd: Unknown symbol can_rx_offload_enable (err -2)
> > [  358.687569] mcp251xfd: Unknown symbol can_rx_offload_get_echo_skb (err -2)
> > [  358.687656] mcp251xfd: Unknown symbol can_dlc2len (err -2)
> > [  358.687710] mcp251xfd: Unknown symbol alloc_can_err_skb (err -2)
> > [  358.687773] mcp251xfd: Unknown symbol can_rx_offload_queue_sorted (err -2)
> > [  358.687819] mcp251xfd: Unknown symbol register_candev (err -2)
> > [  369.092608] CAN device driver interface
> 
> The can-dev module has been loaded *after* mcp251xfd.
> 
> Don't know why autoloading did not work on your machine but doing a
> 'modprobe can-dev' before loading the MCP driver should do it for a test.
> 
> > root@raspberrypi:~# modinfo mcp251xfd
> > filename:
> > /lib/modules/5.4.72-v7l+/kernel/drivers/net/can/spi/mcp251xfd/mcp251xfd.ko
> > license:        GPL v2
> > description:    Microchip MCP251xFD Family CAN controller driver
> > author:         Marc Kleine-Budde <mkl@pengutronix.de>
> > srcversion:     1E05EEB5939E9AB22BA2E1B
> > alias:          spi:mcp251xfd
> > alias:          spi:mcp2518fd
> > alias:          spi:mcp2517fd
> > alias:          of:N*T*Cmicrochip,mcp251xfdC*
> > alias:          of:N*T*Cmicrochip,mcp251xfd
> > alias:          of:N*T*Cmicrochip,mcp2518fdC*
> > alias:          of:N*T*Cmicrochip,mcp2518fd
> > alias:          of:N*T*Cmicrochip,mcp2517fdC*
> > alias:          of:N*T*Cmicrochip,mcp2517fd
> > depends:        can-dev
                    ^^^^^^^
> > intree:         Y
> > name:           mcp251xfd
> > vermagic:       5.4.72-v7l+ SMP mod_unload modversions ARMv7 p2v8

The dependencies are correct. Try running a "depmod -a". If you are on a distro
with udev, manual modprobe should not be needed, as udev should load all needed
modules automatically during boot.

Marc

-- 
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 |

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-25 10:58           ` Marc Kleine-Budde
@ 2020-10-25 17:43             ` Patrick Menschel
  2020-10-25 18:14               ` Marc Kleine-Budde
  0 siblings, 1 reply; 54+ messages in thread
From: Patrick Menschel @ 2020-10-25 17:43 UTC (permalink / raw)
  To: Drew Fustini; +Cc: Marc Kleine-Budde, Oliver Hartkopp, linux-can, Josh S

> 
> The dependencies are correct. Try running a "depmod -a". If you are on a distro
> with udev, manual modprobe should not be needed, as udev should load all needed
> modules automatically during boot.
> 
> Marc
> 

Hi,

I don't know if this helps but I'm currently writing dt-overlays against
rpi-5.4.y. Feel free to use it.

https://github.com/raspberrypi/linux/compare/rpi-5.4.y...menschel:mcp251xfd_overlays

--
Patrick

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-25 17:43             ` Patrick Menschel
@ 2020-10-25 18:14               ` Marc Kleine-Budde
  2020-10-25 18:42                 ` Patrick Menschel
  0 siblings, 1 reply; 54+ messages in thread
From: Marc Kleine-Budde @ 2020-10-25 18:14 UTC (permalink / raw)
  To: Patrick Menschel, Drew Fustini; +Cc: Oliver Hartkopp, linux-can, Josh S


[-- Attachment #1.1: Type: text/plain, Size: 653 bytes --]

On 10/25/20 6:43 PM, Patrick Menschel wrote:
> I don't know if this helps but I'm currently writing dt-overlays against
> rpi-5.4.y. Feel free to use it.

The
https://github.com/marckleinebudde/linux/commits/v5.4-rpi/mcp251xfd-20201022-54
branch already contains overlays:

https://github.com/marckleinebudde/linux/commit/9e02abd4fe591b2d7f369cdaaaf8f1269b7c8693

Marc

-- 
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 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-25 18:14               ` Marc Kleine-Budde
@ 2020-10-25 18:42                 ` Patrick Menschel
  2020-10-26  1:59                   ` Drew Fustini
  0 siblings, 1 reply; 54+ messages in thread
From: Patrick Menschel @ 2020-10-25 18:42 UTC (permalink / raw)
  To: Marc Kleine-Budde, Drew Fustini; +Cc: Oliver Hartkopp, linux-can, Josh S

> The
> https://github.com/marckleinebudde/linux/commits/v5.4-rpi/mcp251xfd-20201022-54
> branch already contains overlays:
> 
> https://github.com/marckleinebudde/linux/commit/9e02abd4fe591b2d7f369cdaaaf8f1269b7c8693
> 
> Marc
> 

OK, I should have known better ;-)

--
Patrick

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-25 18:42                 ` Patrick Menschel
@ 2020-10-26  1:59                   ` Drew Fustini
  2020-10-26  2:50                     ` Drew Fustini
  2020-10-26  7:43                     ` Marc Kleine-Budde
  0 siblings, 2 replies; 54+ messages in thread
From: Drew Fustini @ 2020-10-26  1:59 UTC (permalink / raw)
  To: Patrick Menschel; +Cc: Marc Kleine-Budde, Oliver Hartkopp, linux-can, Josh S

On Sun, Oct 25, 2020 at 1:42 PM Patrick Menschel <menschel.p@posteo.de> wrote:
>
> > The
> > https://github.com/marckleinebudde/linux/commits/v5.4-rpi/mcp251xfd-20201022-54
> > branch already contains overlays:
> >
> > https://github.com/marckleinebudde/linux/commit/9e02abd4fe591b2d7f369cdaaaf8f1269b7c8693
> >
> > Marc
> >
>
> OK, I should have known better ;-)
>
> --
> Patrick

Are there any additional parameters that you are specifying for
"dtoverlay" in config.txt, such as spimaxfrequency?

Thanks,
Drew

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-26  1:59                   ` Drew Fustini
@ 2020-10-26  2:50                     ` Drew Fustini
  2020-10-26  5:16                       ` Patrick Menschel
  2020-10-26  9:40                       ` Marc Kleine-Budde
  2020-10-26  7:43                     ` Marc Kleine-Budde
  1 sibling, 2 replies; 54+ messages in thread
From: Drew Fustini @ 2020-10-26  2:50 UTC (permalink / raw)
  To: Patrick Menschel; +Cc: Marc Kleine-Budde, Oliver Hartkopp, linux-can, Josh S

On Sun, Oct 25, 2020 at 8:59 PM Drew Fustini <drew@beagleboard.org> wrote:
>
> On Sun, Oct 25, 2020 at 1:42 PM Patrick Menschel <menschel.p@posteo.de> wrote:
> >
> > > The
> > > https://github.com/marckleinebudde/linux/commits/v5.4-rpi/mcp251xfd-20201022-54
> > > branch already contains overlays:
> > >
> > > https://github.com/marckleinebudde/linux/commit/9e02abd4fe591b2d7f369cdaaaf8f1269b7c8693
> > >
> > > Marc
> > >
> >
> > OK, I should have known better ;-)
> >
> > --
> > Patrick
>
> Are there any additional parameters that you are specifying for
> "dtoverlay" in config.txt, such as spimaxfrequency?
>
> Thanks,
> Drew

I'm seeing this message which makes me think my issue is that I am not
setting the oscillator as a dtoverlay param.

[    6.873081] CAN device driver interface
[    6.879904] DEBUG mcp251xfd mcp251xfd_probe(): ENTER
[    6.880068] spi_master spi0: will run message pump with realtime priority
[    6.921312] mcp251xfd spi0.0 (unnamed net_device) (uninitialized):
Failed to detect MCP251xFD (osc=0x00000000).

From /boot/config.txt

[pi4]
dtoverlay=mcp251xfd-spi0-0

Could you please share what your experience has been like?

thanks,
drew

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-26  2:50                     ` Drew Fustini
@ 2020-10-26  5:16                       ` Patrick Menschel
  2020-10-26  7:45                         ` Marc Kleine-Budde
  2020-10-26  9:40                       ` Marc Kleine-Budde
  1 sibling, 1 reply; 54+ messages in thread
From: Patrick Menschel @ 2020-10-26  5:16 UTC (permalink / raw)
  To: Drew Fustini; +Cc: Marc Kleine-Budde, Oliver Hartkopp, linux-can, Josh S

>> Are there any additional parameters that you are specifying for
>> "dtoverlay" in config.txt, such as spimaxfrequency?
>>
>> Thanks,
>> Drew
> 
> I'm seeing this message which makes me think my issue is that I am not
> setting the oscillator as a dtoverlay param.
> 
> [    6.873081] CAN device driver interface
> [    6.879904] DEBUG mcp251xfd mcp251xfd_probe(): ENTER
> [    6.880068] spi_master spi0: will run message pump with realtime priority
> [    6.921312] mcp251xfd spi0.0 (unnamed net_device) (uninitialized):
> Failed to detect MCP251xFD (osc=0x00000000).
> 
> From /boot/config.txt
> 
> [pi4]
> dtoverlay=mcp251xfd-spi0-0
> 
> Could you please share what your experience has been like?
> 
> thanks,
> drew
> 

I'm lacking hw currently, so I haven't tested yet.

I believe OSC has to be set, so for a 40Mhz crystal
dtoverlay=mcp251xfd-spi0-0,osc=40000000

--
Patrick

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-26  1:59                   ` Drew Fustini
  2020-10-26  2:50                     ` Drew Fustini
@ 2020-10-26  7:43                     ` Marc Kleine-Budde
  1 sibling, 0 replies; 54+ messages in thread
From: Marc Kleine-Budde @ 2020-10-26  7:43 UTC (permalink / raw)
  To: Drew Fustini, Patrick Menschel; +Cc: Oliver Hartkopp, linux-can, Josh S


[-- Attachment #1.1: Type: text/plain, Size: 927 bytes --]

On 10/26/20 2:59 AM, Drew Fustini wrote:
>>> The
>>> https://github.com/marckleinebudde/linux/commits/v5.4-rpi/mcp251xfd-20201022-54
>>> branch already contains overlays:
>>>
>>> https://github.com/marckleinebudde/linux/commit/9e02abd4fe591b2d7f369cdaaaf8f1269b7c8693

> Are there any additional parameters that you are specifying for
> "dtoverlay" in config.txt, such as spimaxfrequency?

Usually I only specify the IRQ.

E.g.: For the

    https://wiki.seeedstudio.com/2-Channel-CAN-BUS-FD-Shield-for-Raspberry-Pi/

board I'm using:

dtoverlay=mcp251xfd-spi0-0,interrupt=25
dtoverlay=mcp251xfd-spi1-0,interrupt=24

regards,
Marc

-- 
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 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-26  5:16                       ` Patrick Menschel
@ 2020-10-26  7:45                         ` Marc Kleine-Budde
  0 siblings, 0 replies; 54+ messages in thread
From: Marc Kleine-Budde @ 2020-10-26  7:45 UTC (permalink / raw)
  To: Patrick Menschel, Drew Fustini; +Cc: Oliver Hartkopp, linux-can, Josh S


[-- Attachment #1.1: Type: text/plain, Size: 573 bytes --]

On 10/26/20 6:16 AM, Patrick Menschel wrote:
> I'm lacking hw currently, so I haven't tested yet.
> 
> I believe OSC has to be set, so for a 40Mhz crystal
> dtoverlay=mcp251xfd-spi0-0,osc=40000000

An OSC of 40 MHz is default, but you can overwrite it using
"oscillator=<FREQ_IN_HZ>"

Marc

-- 
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 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-26  2:50                     ` Drew Fustini
  2020-10-26  5:16                       ` Patrick Menschel
@ 2020-10-26  9:40                       ` Marc Kleine-Budde
  2020-10-26 16:51                         ` Patrick Menschel
  1 sibling, 1 reply; 54+ messages in thread
From: Marc Kleine-Budde @ 2020-10-26  9:40 UTC (permalink / raw)
  To: Drew Fustini, Patrick Menschel; +Cc: Oliver Hartkopp, linux-can, Josh S


[-- Attachment #1.1: Type: text/plain, Size: 892 bytes --]

On 10/26/20 3:50 AM, Drew Fustini wrote:
> I'm seeing this message which makes me think my issue is that I am not
> setting the oscillator as a dtoverlay param.
> 
> [    6.873081] CAN device driver interface
> [    6.879904] DEBUG mcp251xfd mcp251xfd_probe(): ENTER
> [    6.880068] spi_master spi0: will run message pump with realtime priority
> [    6.921312] mcp251xfd spi0.0 (unnamed net_device) (uninitialized):
> Failed to detect MCP251xFD (osc=0x00000000).
> 
> From /boot/config.txt
> 
> [pi4]
> dtoverlay=mcp251xfd-spi0-0

Are you using CS0 of spi0?
What's the frequency of your OSC?

Marc

-- 
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 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-26  9:40                       ` Marc Kleine-Budde
@ 2020-10-26 16:51                         ` Patrick Menschel
  2020-10-26 17:00                           ` Marc Kleine-Budde
  0 siblings, 1 reply; 54+ messages in thread
From: Patrick Menschel @ 2020-10-26 16:51 UTC (permalink / raw)
  To: Marc Kleine-Budde, Drew Fustini; +Cc: Oliver Hartkopp, linux-can, Josh S

> On 10/26/20 3:50 AM, Drew Fustini wrote:
>> I'm seeing this message which makes me think my issue is that I am not
>> setting the oscillator as a dtoverlay param.
>>
>> [    6.873081] CAN device driver interface
>> [    6.879904] DEBUG mcp251xfd mcp251xfd_probe(): ENTER
>> [    6.880068] spi_master spi0: will run message pump with realtime priority
>> [    6.921312] mcp251xfd spi0.0 (unnamed net_device) (uninitialized):
>> Failed to detect MCP251xFD (osc=0x00000000).
>>
>> From /boot/config.txt
>>
>> [pi4]
>> dtoverlay=mcp251xfd-spi0-0
> 
> Are you using CS0 of spi0?
> What's the frequency of your OSC?
> 
> Marc
> 

mcp251xfd_osc_invalid(osc) is true according to the string.

https://github.com/marckleinebudde/linux/blob/v5.4-rpi/mcp251xfd-20201022-54/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c#L552

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-26 16:51                         ` Patrick Menschel
@ 2020-10-26 17:00                           ` Marc Kleine-Budde
  2020-10-27  2:22                             ` Drew Fustini
  0 siblings, 1 reply; 54+ messages in thread
From: Marc Kleine-Budde @ 2020-10-26 17:00 UTC (permalink / raw)
  To: Patrick Menschel, Drew Fustini; +Cc: Oliver Hartkopp, linux-can, Josh S


[-- Attachment #1.1: Type: text/plain, Size: 1499 bytes --]

On 10/26/20 5:51 PM, Patrick Menschel wrote:
>> On 10/26/20 3:50 AM, Drew Fustini wrote:
>>> I'm seeing this message which makes me think my issue is that I am not
>>> setting the oscillator as a dtoverlay param.
>>>
>>> [    6.873081] CAN device driver interface
>>> [    6.879904] DEBUG mcp251xfd mcp251xfd_probe(): ENTER
>>> [    6.880068] spi_master spi0: will run message pump with realtime priority
>>> [    6.921312] mcp251xfd spi0.0 (unnamed net_device) (uninitialized):
>>> Failed to detect MCP251xFD (osc=0x00000000).
                                    ^^^^^^^^^^

Contents of OSC register.

>>> [pi4]
>>> dtoverlay=mcp251xfd-spi0-0
>>
>> Are you using CS0 of spi0?
>> What's the frequency of your OSC?
> 
> mcp251xfd_osc_invalid(osc) is true according to the string.
> 
> https://github.com/marckleinebudde/linux/blob/v5.4-rpi/mcp251xfd-20201022-54/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c#L552

ACK

The OSC register would never contain 0x0. So when reading 0x0 (or 0xff) you have
not read anything. This is what the "invalid" test does.

This could have several reasons, e.g. mcp2518fd is not on SPI0 CS0, or the OSC
is 20 MHz, but the DT specifies an OSC of 40 MHz.

Marc

-- 
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 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-26 17:00                           ` Marc Kleine-Budde
@ 2020-10-27  2:22                             ` Drew Fustini
  2020-10-27  6:35                               ` Drew Fustini
  0 siblings, 1 reply; 54+ messages in thread
From: Drew Fustini @ 2020-10-27  2:22 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: Patrick Menschel, Oliver Hartkopp, linux-can, Josh S

Thank you the feedback.

I think it may be any issue with spi interface and/or chip select config.

[    6.812079] DEBUG mcp251xfd mcp251xfd_probe(): ENTER
[    6.812174] mcp251xfd spi0.0: DEBUG mcp251xfd mcp251xfd_probe():
devm_clk_get()
[    6.812208] mcp251xfd spi0.0: DEBUG mcp251xfd mcp251xfd_probe():
feq=0x2625a00
[    6.850106] mcp251xfd spi0.0 (unnamed net_device) (uninitialized):
Failed to detect MCP251xFD (osc=0x00000000).

This proves that the driver is getting the 40 MHz from the device tree
properties.  The board does have a 40 MHz osc.

It is the Waveshare CANFD Hat [1].  They have their own tarball for
download [2] with a mcp25xxfd driver that is copyright 2019 by Martin
Sperl <kernel@martin.sperl.org>.  I'm looking at that to see why it
works and the newer, proper driver does not.

Thanks,
Drew

[1] https://www.waveshare.com/wiki/2-CH_CAN_FD_HAT
[2] https://www.waveshare.com/wiki/File:2-CH-CAN-FD-HAT-Demo.7z


On Mon, Oct 26, 2020 at 12:00 PM Marc Kleine-Budde <mkl@pengutronix.de> wrote:
>
> On 10/26/20 5:51 PM, Patrick Menschel wrote:
> >> On 10/26/20 3:50 AM, Drew Fustini wrote:
> >>> I'm seeing this message which makes me think my issue is that I am not
> >>> setting the oscillator as a dtoverlay param.
> >>>
> >>> [    6.873081] CAN device driver interface
> >>> [    6.879904] DEBUG mcp251xfd mcp251xfd_probe(): ENTER
> >>> [    6.880068] spi_master spi0: will run message pump with realtime priority
> >>> [    6.921312] mcp251xfd spi0.0 (unnamed net_device) (uninitialized):
> >>> Failed to detect MCP251xFD (osc=0x00000000).
>                                     ^^^^^^^^^^
>
> Contents of OSC register.
>
> >>> [pi4]
> >>> dtoverlay=mcp251xfd-spi0-0
> >>
> >> Are you using CS0 of spi0?
> >> What's the frequency of your OSC?
> >
> > mcp251xfd_osc_invalid(osc) is true according to the string.
> >
> > https://github.com/marckleinebudde/linux/blob/v5.4-rpi/mcp251xfd-20201022-54/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c#L552
>
> ACK
>
> The OSC register would never contain 0x0. So when reading 0x0 (or 0xff) you have
> not read anything. This is what the "invalid" test does.
>
> This could have several reasons, e.g. mcp2518fd is not on SPI0 CS0, or the OSC
> is 20 MHz, but the DT specifies an OSC of 40 MHz.
>
> Marc
>
> --
> 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 |
>

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-27  2:22                             ` Drew Fustini
@ 2020-10-27  6:35                               ` Drew Fustini
  2020-10-27  7:06                                 ` Marc Kleine-Budde
  0 siblings, 1 reply; 54+ messages in thread
From: Drew Fustini @ 2020-10-27  6:35 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: Patrick Menschel, Oliver Hartkopp, linux-can, Josh S

On Mon, Oct 26, 2020 at 9:22 PM Drew Fustini <drew@beagleboard.org> wrote:
>
> Thank you the feedback.
>
> I think it may be any issue with spi interface and/or chip select config.
>
> [    6.812079] DEBUG mcp251xfd mcp251xfd_probe(): ENTER
> [    6.812174] mcp251xfd spi0.0: DEBUG mcp251xfd mcp251xfd_probe():
> devm_clk_get()
> [    6.812208] mcp251xfd spi0.0: DEBUG mcp251xfd mcp251xfd_probe():
> feq=0x2625a00
> [    6.850106] mcp251xfd spi0.0 (unnamed net_device) (uninitialized):
> Failed to detect MCP251xFD (osc=0x00000000).
>
> This proves that the driver is getting the 40 MHz from the device tree
> properties.  The board does have a 40 MHz osc.
>
> It is the Waveshare CANFD Hat [1].  They have their own tarball for
> download [2] with a mcp25xxfd driver that is copyright 2019 by Martin
> Sperl <kernel@martin.sperl.org>.  I'm looking at that to see why it
> works and the newer, proper driver does not.
>
> Thanks,
> Drew
>
> [1] https://www.waveshare.com/wiki/2-CH_CAN_FD_HAT
> [2] https://www.waveshare.com/wiki/File:2-CH-CAN-FD-HAT-Demo.7z

This is the overlay that the Waveshare download is using:
https://gist.github.com/pdp7/784d0ba8b9648d20ab055747ec945225

It is different but I'm having trouble understanding why it works and
the new overlay for the newer driver does not.

-Drew

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-27  6:35                               ` Drew Fustini
@ 2020-10-27  7:06                                 ` Marc Kleine-Budde
  2020-10-27 18:18                                   ` Patrick Menschel
  0 siblings, 1 reply; 54+ messages in thread
From: Marc Kleine-Budde @ 2020-10-27  7:06 UTC (permalink / raw)
  To: Drew Fustini; +Cc: Patrick Menschel, Oliver Hartkopp, linux-can, Josh S


[-- Attachment #1.1: Type: text/plain, Size: 1234 bytes --]

On 10/27/20 7:35 AM, Drew Fustini wrote:
>> It is the Waveshare CANFD Hat [1].  They have their own tarball for
>> download [2] with a mcp25xxfd driver that is copyright 2019 by Martin
>> Sperl <kernel@martin.sperl.org>.  I'm looking at that to see why it
>> works and the newer, proper driver does not.
>>
>> Thanks,
>> Drew
>>
>> [1] https://www.waveshare.com/wiki/2-CH_CAN_FD_HAT
>> [2] https://www.waveshare.com/wiki/File:2-CH-CAN-FD-HAT-Demo.7z
> 
> This is the overlay that the Waveshare download is using:
> https://gist.github.com/pdp7/784d0ba8b9648d20ab055747ec945225
> 
> It is different but I'm having trouble understanding why it works and
> the new overlay for the newer driver does not.

Have you actually tested the waveshare driver and overlay with your setup?

If you have a scope or logic analyser attach it to SPI bus (MISO, MOSI, Clock,
Chipselect and the IRQ Line of the Chip) and check what's going on there.

Marc

-- 
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 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-27  7:06                                 ` Marc Kleine-Budde
@ 2020-10-27 18:18                                   ` Patrick Menschel
  2020-10-27 18:22                                     ` Marc Kleine-Budde
  0 siblings, 1 reply; 54+ messages in thread
From: Patrick Menschel @ 2020-10-27 18:18 UTC (permalink / raw)
  To: Marc Kleine-Budde, Drew Fustini; +Cc: Oliver Hartkopp, linux-can, Josh S


>> It is different but I'm having trouble understanding why it works and
>> the new overlay for the newer driver does not.
> 
> Have you actually tested the waveshare driver and overlay with your setup?
> 
> If you have a scope or logic analyser attach it to SPI bus (MISO, MOSI, Clock,
> Chipselect and the IRQ Line of the Chip) and check what's going on there.
> 
> Marc
> 

Is the target path for clocks correct?

I mean "/clocks"

https://gist.github.com/pdp7/784d0ba8b9648d20ab055747ec945225#file-2xmcp2517fd-overlay-dts-L49

instead of "/"

https://github.com/marckleinebudde/linux/blob/v5.4-rpi/mcp251xfd-20201022-54/arch/arm/boot/dts/overlays/mcp251xfd-spi0-0-overlay.dts#L38

--
Patrick

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-27 18:18                                   ` Patrick Menschel
@ 2020-10-27 18:22                                     ` Marc Kleine-Budde
  2020-10-28  1:57                                       ` Drew Fustini
  0 siblings, 1 reply; 54+ messages in thread
From: Marc Kleine-Budde @ 2020-10-27 18:22 UTC (permalink / raw)
  To: Patrick Menschel, Drew Fustini; +Cc: Oliver Hartkopp, linux-can, Josh S


[-- Attachment #1.1: Type: text/plain, Size: 1516 bytes --]

On 10/27/20 7:18 PM, Patrick Menschel wrote:
> 
>>> It is different but I'm having trouble understanding why it works and
>>> the new overlay for the newer driver does not.
>>
>> Have you actually tested the waveshare driver and overlay with your setup?
>>
>> If you have a scope or logic analyser attach it to SPI bus (MISO, MOSI, Clock,
>> Chipselect and the IRQ Line of the Chip) and check what's going on there.
>>
>> Marc
>>
> 
> Is the target path for clocks correct?
> 
> I mean "/clocks"

It doesn't matter where you put them...
 
> https://gist.github.com/pdp7/784d0ba8b9648d20ab055747ec945225#file-2xmcp2517fd-overlay-dts-L49
> 
> instead of "/"
> 
> https://github.com/marckleinebudde/linux/blob/v5.4-rpi/mcp251xfd-20201022-54/arch/arm/boot/dts/overlays/mcp251xfd-spi0-0-overlay.dts#L38

The mcp251xfd node references them via the label ("<&can_osc>"):

https://github.com/marckleinebudde/linux/blob/v5.4-rpi/mcp251xfd-20201022-54/arch/arm/boot/dts/overlays/mcp251xfd-spi0-0-overlay.dts#L61

The driver will bail out even earlier if no clock is found:

https://github.com/marckleinebudde/linux/blob/v5.4-rpi/mcp251xfd-20201022-54/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c#L2764

regards
Marc

-- 
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 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-27 18:22                                     ` Marc Kleine-Budde
@ 2020-10-28  1:57                                       ` Drew Fustini
  2020-10-28  3:47                                         ` Drew Fustini
  0 siblings, 1 reply; 54+ messages in thread
From: Drew Fustini @ 2020-10-28  1:57 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: Patrick Menschel, Oliver Hartkopp, linux-can, Josh S

On Tue, Oct 27, 2020 at 1:23 PM Marc Kleine-Budde <mkl@pengutronix.de> wrote:
>
> On 10/27/20 7:18 PM, Patrick Menschel wrote:
> >
> >>> It is different but I'm having trouble understanding why it works and
> >>> the new overlay for the newer driver does not.
> >>
> >> Have you actually tested the waveshare driver and overlay with your setup?
> >>
> >> If you have a scope or logic analyser attach it to SPI bus (MISO, MOSI, Clock,
> >> Chipselect and the IRQ Line of the Chip) and check what's going on there.
> >>
> >> Marc
> >>
> >
> > Is the target path for clocks correct?
> >
> > I mean "/clocks"
>
> It doesn't matter where you put them...
>
> > https://gist.github.com/pdp7/784d0ba8b9648d20ab055747ec945225#file-2xmcp2517fd-overlay-dts-L49
> >
> > instead of "/"
> >
> > https://github.com/marckleinebudde/linux/blob/v5.4-rpi/mcp251xfd-20201022-54/arch/arm/boot/dts/overlays/mcp251xfd-spi0-0-overlay.dts#L38
>
> The mcp251xfd node references them via the label ("<&can_osc>"):
>
> https://github.com/marckleinebudde/linux/blob/v5.4-rpi/mcp251xfd-20201022-54/arch/arm/boot/dts/overlays/mcp251xfd-spi0-0-overlay.dts#L61
>
> The driver will bail out even earlier if no clock is found:
>
> https://github.com/marckleinebudde/linux/blob/v5.4-rpi/mcp251xfd-20201022-54/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c#L2764
>
> regards
> Marc
>
> --
> 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 |
>

Thank you for the suggestions.  I've not been as multi-tasking as I
hoped during ELC-E :)

I assumed the Waveshare instructions work but that is error on my part
for not actually reproducing.  That is what I will do first.
Ultimately, I want the freshly upstreamed driver working but I should
check if their driver tarball works.

thanks,
drew

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-28  1:57                                       ` Drew Fustini
@ 2020-10-28  3:47                                         ` Drew Fustini
  2020-10-28  7:57                                           ` Marc Kleine-Budde
  0 siblings, 1 reply; 54+ messages in thread
From: Drew Fustini @ 2020-10-28  3:47 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: Patrick Menschel, Oliver Hartkopp, linux-can, Josh S

On Tue, Oct 27, 2020 at 8:57 PM Drew Fustini <drew@beagleboard.org> wrote:
>
> On Tue, Oct 27, 2020 at 1:23 PM Marc Kleine-Budde <mkl@pengutronix.de> wrote:
> >
> > On 10/27/20 7:18 PM, Patrick Menschel wrote:
> > >
> > >>> It is different but I'm having trouble understanding why it works and
> > >>> the new overlay for the newer driver does not.
> > >>
> > >> Have you actually tested the waveshare driver and overlay with your setup?
> > >>
> > >> If you have a scope or logic analyser attach it to SPI bus (MISO, MOSI, Clock,
> > >> Chipselect and the IRQ Line of the Chip) and check what's going on there.
> > >>
> > >> Marc
> > >>
> > >
> > > Is the target path for clocks correct?
> > >
> > > I mean "/clocks"
> >
> > It doesn't matter where you put them...
> >
> > > https://gist.github.com/pdp7/784d0ba8b9648d20ab055747ec945225#file-2xmcp2517fd-overlay-dts-L49
> > >
> > > instead of "/"
> > >
> > > https://github.com/marckleinebudde/linux/blob/v5.4-rpi/mcp251xfd-20201022-54/arch/arm/boot/dts/overlays/mcp251xfd-spi0-0-overlay.dts#L38
> >
> > The mcp251xfd node references them via the label ("<&can_osc>"):
> >
> > https://github.com/marckleinebudde/linux/blob/v5.4-rpi/mcp251xfd-20201022-54/arch/arm/boot/dts/overlays/mcp251xfd-spi0-0-overlay.dts#L61
> >
> > The driver will bail out even earlier if no clock is found:
> >
> > https://github.com/marckleinebudde/linux/blob/v5.4-rpi/mcp251xfd-20201022-54/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c#L2764
> >
> > regards
> > Marc
> >
> > --
> > 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 |
> >
>
> Thank you for the suggestions.  I've not been as multi-tasking as I
> hoped during ELC-E :)
>
> I assumed the Waveshare instructions work but that is error on my part
> for not actually reproducing.  That is what I will do first.
> Ultimately, I want the freshly upstreamed driver working but I should
> check if their driver tarball works.
>
> thanks,
> drew

The Waveshare installer uses the 4.19 kernel with the mcp25xxfd
driver.  However, it also fails, sio I think I need to dig deeper:

pi@raspberrypi:~ $ dmesg | grep -Ei spi\|can
[    4.263765] CAN device driver interface
[    4.286258] mcp25xxfd_can: loading out-of-tree module taints kernel.
[    5.477511] mcp25xxfd spi1.0: Cannot initialize MCP2517. Wrong
wiring? (oscilator register reads as 00000000)
[    5.477530] mcp25xxfd spi1.0: Probe failed, err=19
[    5.490325] mcp25xxfd spi0.0: Cannot initialize MCP2517. Wrong
wiring? (oscilator register reads as 00000000)
[    5.490352] mcp25xxfd spi0.0: Probe failed, err=19
[    5.490459] spi-bcm2835 fe204000.spi: chipselect 0 already in use
[    5.490479] spi_master spi0: spi_device register error
/soc/spi@7e204000/mcp251xfd@0
[    5.490497] spi_master spi0: Failed to create SPI device for
/soc/spi@7e204000/mcp251xfd@0

pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.19.75-v7l+ #1270 SMP Tue Sep 24 18:51:41 BST 2019
armv7l GNU/Linux
pi@raspberrypi:~ $ modinfo
/lib/modules/4.19.75-v7l+/kernel/drivers/net/can/spi/mcp25xxfd-can.ko
filename:
/lib/modules/4.19.75-v7l+/kernel/drivers/net/can/spi/mcp25xxfd-can.ko
license:        GPL v2
description:    Microchip 25XXFD CAN driver
author:         Martin Sperl <kernel@martin.sperl.org>
srcversion:     EE1DD0B30B5F99540B43858
alias:          of:N*T*Cmicrochip,mcp2517fdC*
alias:          of:N*T*Cmicrochip,mcp2517fd
alias:          spi:mcp2517fd
depends:        can-dev
name:           mcp25xxfd_can
vermagic:       4.19.75-v7l+ SMP mod_unload modversions ARMv7 p2v8
parm:           rx_prefetch_bytes:number of bytes to blindly prefetch
when reading a rx-fifo (uint)
parm:           reschedule_int_thread_after:Reschedule the interrupt
thread after this many loops
 (uint)
parm:           tx_fifos:Number of tx-fifos to configure
 (uint)
parm:           three_shot:Use 3 shots when one-shot is requested (bool)
parm:           bw_sharing_log2bits:Delay between 2 transmissions in
number of arbitration bit times
 (uint)
parm:           enable_edge_filter:Enable ISO11898-1:2015 edge_filtering (bool)
parm:           tdc_mode:Transmitter Delay Mode - 0 = disabled, 1 =
fixed, 2 = auto
 (uint)
parm:           tdc_value:Transmission Delay Value - range: [0:63] SCLK (uint)
parm:           tdc_offset:Transmission Delay offset - range: [-64:63]
SCLK (int)


thanks,
drew

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-28  3:47                                         ` Drew Fustini
@ 2020-10-28  7:57                                           ` Marc Kleine-Budde
  2020-10-31 12:27                                             ` Drew Fustini
  0 siblings, 1 reply; 54+ messages in thread
From: Marc Kleine-Budde @ 2020-10-28  7:57 UTC (permalink / raw)
  To: Drew Fustini; +Cc: Patrick Menschel, Oliver Hartkopp, linux-can, Josh S


[-- Attachment #1.1: Type: text/plain, Size: 1098 bytes --]

On 10/28/20 4:47 AM, Drew Fustini wrote:
>> I assumed the Waveshare instructions work but that is error on my part
>> for not actually reproducing.  That is what I will do first.
>> Ultimately, I want the freshly upstreamed driver working but I should
>> check if their driver tarball works.
> 
> The Waveshare installer uses the 4.19 kernel with the mcp25xxfd
> driver.  However, it also fails, sio I think I need to dig deeper:
> 
> pi@raspberrypi:~ $ dmesg | grep -Ei spi\|can
> [    4.263765] CAN device driver interface
> [    4.286258] mcp25xxfd_can: loading out-of-tree module taints kernel.
> [    5.477511] mcp25xxfd spi1.0: Cannot initialize MCP2517. Wrong
> wiring? (oscilator register reads as 00000000)

It reads the osc as 0x0, too. This is the same error as you've seen with my driver.

Marc

-- 
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 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-28  7:57                                           ` Marc Kleine-Budde
@ 2020-10-31 12:27                                             ` Drew Fustini
  2020-10-31 15:14                                               ` Patrick Menschel
  2020-11-02  7:26                                               ` Marc Kleine-Budde
  0 siblings, 2 replies; 54+ messages in thread
From: Drew Fustini @ 2020-10-31 12:27 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: Patrick Menschel, Oliver Hartkopp, linux-can, Josh S

On Wed, Oct 28, 2020 at 8:58 AM Marc Kleine-Budde <mkl@pengutronix.de> wrote:
>
> On 10/28/20 4:47 AM, Drew Fustini wrote:
> >> I assumed the Waveshare instructions work but that is error on my part
> >> for not actually reproducing.  That is what I will do first.
> >> Ultimately, I want the freshly upstreamed driver working but I should
> >> check if their driver tarball works.
> >
> > The Waveshare installer uses the 4.19 kernel with the mcp25xxfd
> > driver.  However, it also fails, sio I think I need to dig deeper:
> >
> > pi@raspberrypi:~ $ dmesg | grep -Ei spi\|can
> > [    4.263765] CAN device driver interface
> > [    4.286258] mcp25xxfd_can: loading out-of-tree module taints kernel.
> > [    5.477511] mcp25xxfd spi1.0: Cannot initialize MCP2517. Wrong
> > wiring? (oscilator register reads as 00000000)
>
> It reads the osc as 0x0, too. This is the same error as you've seen with my driver.
>
> Marc
>
> --
> 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 |


Alright, it looks like I had faulty hardware!  I got a Waveshare CAN
FD hat and both the old waveshare-provided driver and the new
mcp251xfd driver work.

Well, at least for can0 with mcp251xfd-spi0-0:

[   14.530587] CAN device driver interface
[   14.548941] mcp251xfd spi0.0: DEBUG mcp251xfd mcp251xfd_probe():
devm_clk_get()
[   14.548977] mcp251xfd spi0.0: DEBUG mcp251xfd mcp251xfd_probe(): feq=40000000
[   14.549045] spi_master spi0: will run message pump with realtime priority
[   14.562946] mcp251xfd spi0.0 can0: MCP2517FD rev0.0 (-RX_INT
+MAB_NO_WARN +CRC_REG +CRC_RX +CRC_TX +ECC -HD c:40.00MHz m:20.00MHz
r:17.00MHz e:0.00MHz) successfully initialized.

However, I am still trying to figure out can1.  I tried
mcp251xfd-spi0-1 and mcp251xfd-spi1-0 but neither was able to
initialize the device.  I am using:

commit 9e02abd4fe591b2d7f369cdaaaf8f1269b7c8693 (HEAD ->
v5.4-rpi/mcp251xfd-20201022-54, marc/v5.4-rpi/mcp251xfd-20201022-54)
Author: Marc Kleine-Budde <mkl@pengutronix.de>
Date:   Fri Nov 15 00:54:07 2019 +0100

    mcp251xfd-spi0-0, mcp251xfd-spi0-1, mcp251xfd-spi1-0: add overlays

    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

I'll try tweaking it a bit and see if I get any further.

Thanks,
Drew

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-31 12:27                                             ` Drew Fustini
@ 2020-10-31 15:14                                               ` Patrick Menschel
  2020-10-31 15:35                                                 ` Patrick Menschel
  2020-11-02  7:55                                                 ` Marc Kleine-Budde
  2020-11-02  7:26                                               ` Marc Kleine-Budde
  1 sibling, 2 replies; 54+ messages in thread
From: Patrick Menschel @ 2020-10-31 15:14 UTC (permalink / raw)
  To: Drew Fustini, Marc Kleine-Budde; +Cc: Oliver Hartkopp, linux-can, Josh S

> Alright, it looks like I had faulty hardware!  I got a Waveshare CAN
> FD hat and both the old waveshare-provided driver and the new
> mcp251xfd driver work.
> 
> Well, at least for can0 with mcp251xfd-spi0-0:
> 
> [   14.530587] CAN device driver interface
> [   14.548941] mcp251xfd spi0.0: DEBUG mcp251xfd mcp251xfd_probe():
> devm_clk_get()
> [   14.548977] mcp251xfd spi0.0: DEBUG mcp251xfd mcp251xfd_probe(): feq=40000000
> [   14.549045] spi_master spi0: will run message pump with realtime priority
> [   14.562946] mcp251xfd spi0.0 can0: MCP2517FD rev0.0 (-RX_INT
> +MAB_NO_WARN +CRC_REG +CRC_RX +CRC_TX +ECC -HD c:40.00MHz m:20.00MHz
> r:17.00MHz e:0.00MHz) successfully initialized.
> 
> However, I am still trying to figure out can1.  I tried
> mcp251xfd-spi0-1 and mcp251xfd-spi1-0 but neither was able to
> initialize the device.  I am using:
> 
> commit 9e02abd4fe591b2d7f369cdaaaf8f1269b7c8693 (HEAD ->
> v5.4-rpi/mcp251xfd-20201022-54, marc/v5.4-rpi/mcp251xfd-20201022-54)
> Author: Marc Kleine-Budde <mkl@pengutronix.de>
> Date:   Fri Nov 15 00:54:07 2019 +0100
> 
>     mcp251xfd-spi0-0, mcp251xfd-spi0-1, mcp251xfd-spi1-0: add overlays
> 
>     Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> 
> I'll try tweaking it a bit and see if I get any further.
> 
> Thanks,
> Drew
> 

I believe Waveshare did choose other interrupt pins.
Marc used 24 25 which I also chose for a pHat I'm currently making
schematics for.

Try these lines in /boot/config.txt

dtoverlay=mcp251xfd-spi0-0,interrupt=25
dtoverlay=mcp251xfd-spi1-0,interrupt=16

The waveshare overlay is strange in one point. It uses Pin 26 (instead
of 18) for Chip selection but that is no chip select pin. This can work
if the pin is output and luckily pulls the CE line in the right direction.

https://gist.github.com/pdp7/784d0ba8b9648d20ab055747ec945225#file-2xmcp2517fd-overlay-dts-L40

https://pinout.xyz/pinout/pin37_gpio26#

Maybe this has something to do with Nvidia Jetson Platform.

--
Patrick

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-31 15:14                                               ` Patrick Menschel
@ 2020-10-31 15:35                                                 ` Patrick Menschel
  2020-10-31 21:57                                                   ` Drew Fustini
  2020-11-02  7:55                                                 ` Marc Kleine-Budde
  1 sibling, 1 reply; 54+ messages in thread
From: Patrick Menschel @ 2020-10-31 15:35 UTC (permalink / raw)
  To: Drew Fustini, Marc Kleine-Budde; +Cc: Oliver Hartkopp, linux-can, Josh S

> I believe Waveshare did choose other interrupt pins.
> Marc used 24 25 which I also chose for a pHat I'm currently making
> schematics for.
> 
> Try these lines in /boot/config.txt
> 
> dtoverlay=mcp251xfd-spi0-0,interrupt=25
> dtoverlay=mcp251xfd-spi1-0,interrupt=16
> 
> The waveshare overlay is strange in one point. It uses Pin 26 (instead
> of 18) for Chip selection but that is no chip select pin. This can work
> if the pin is output and luckily pulls the CE line in the right direction.
> 
> https://gist.github.com/pdp7/784d0ba8b9648d20ab055747ec945225#file-2xmcp2517fd-overlay-dts-L40
> 
> https://pinout.xyz/pinout/pin37_gpio26#
> 
> Maybe this has something to do with Nvidia Jetson Platform.
> 
> --
> Patrick
> 

Apparently Pin 26 is CE1 for SPI5, only available on Pi 4.

https://github.com/raspberrypi/firmware/blob/master/boot/overlays/README#L2674

--
Patrick

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-31 15:35                                                 ` Patrick Menschel
@ 2020-10-31 21:57                                                   ` Drew Fustini
  2020-11-01 22:49                                                     ` Drew Fustini
  2020-11-02  8:18                                                     ` Marc Kleine-Budde
  0 siblings, 2 replies; 54+ messages in thread
From: Drew Fustini @ 2020-10-31 21:57 UTC (permalink / raw)
  To: Patrick Menschel; +Cc: Marc Kleine-Budde, Oliver Hartkopp, linux-can, Josh S

On Sat, Oct 31, 2020 at 4:35 PM Patrick Menschel <menschel.p@posteo.de> wrote:
>
> > I believe Waveshare did choose other interrupt pins.
> > Marc used 24 25 which I also chose for a pHat I'm currently making
> > schematics for.
> >
> > Try these lines in /boot/config.txt
> >
> > dtoverlay=mcp251xfd-spi0-0,interrupt=25
> > dtoverlay=mcp251xfd-spi1-0,interrupt=16
> >
> > The waveshare overlay is strange in one point. It uses Pin 26 (instead
> > of 18) for Chip selection but that is no chip select pin. This can work
> > if the pin is output and luckily pulls the CE line in the right direction.
> >
> > https://gist.github.com/pdp7/784d0ba8b9648d20ab055747ec945225#file-2xmcp2517fd-overlay-dts-L40
> >
> > https://pinout.xyz/pinout/pin37_gpio26#
> >
> > Maybe this has something to do with Nvidia Jetson Platform.
> >
> > --
> > Patrick
> >
>
> Apparently Pin 26 is CE1 for SPI5, only available on Pi 4.
>
> https://github.com/raspberrypi/firmware/blob/master/boot/overlays/README#L2674
>
> --
> Patrick

Thank you!  That appears to have solved the problem:

#dtoverlay=2xMCP2517FD
pi@raspberrypi:~$ dmesg | grep -Ei can\|spi
[    5.916785] DEBUG spi.c spi_setup(): ENTER
[    5.917056] DEBUG spi.c spi_setup(): ENTER
[    5.960326] DEBUG spi.c spi_setup(): ENTER
[    6.897919] CAN device driver interface
[    6.904530] mcp251xfd spi0.0: DEBUG mcp251xfd mcp251xfd_probe():
devm_clk_get()
[    6.904574] mcp251xfd spi0.0: DEBUG mcp251xfd mcp251xfd_probe(): feq=40000000
[    6.904641] DEBUG spi.c spi_setup(): ENTER
[    6.904658] spi_master spi0: will run message pump with realtime priority
[    6.912009] mcp251xfd spi0.0 can0: MCP2517FD rev0.0 (-RX_INT
+MAB_NO_WARN +CRC_REG +CRC_RX +CRC_TX +ECC -HD c:40.00MHz m:20.00MHz
r:17.00MHz e:0.00MHz) successfully initialized.
[    6.912613] mcp251xfd spi1.0: DEBUG mcp251xfd mcp251xfd_probe():
devm_clk_get()
[    6.912646] mcp251xfd spi1.0: DEBUG mcp251xfd mcp251xfd_probe(): feq=40000000
[    6.912701] DEBUG spi.c spi_setup(): ENTER
[    6.912719] spi_master spi1: will run message pump with realtime priority
[    6.920067] mcp251xfd spi1.0 can1: MCP2517FD rev0.0 (-RX_INT
+MAB_NO_WARN +CRC_REG +CRC_RX +CRC_TX +ECC -HD c:40.00MHz m:20.00MHz
r:17.00MHz e:0.00MHz) successfully initialized.


Thanks,
Drew

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-31 21:57                                                   ` Drew Fustini
@ 2020-11-01 22:49                                                     ` Drew Fustini
  2020-11-02  7:25                                                       ` Marc Kleine-Budde
  2020-11-02  8:18                                                     ` Marc Kleine-Budde
  1 sibling, 1 reply; 54+ messages in thread
From: Drew Fustini @ 2020-11-01 22:49 UTC (permalink / raw)
  To: Patrick Menschel; +Cc: Marc Kleine-Budde, Oliver Hartkopp, linux-can, Josh S

On Sat, Oct 31, 2020 at 10:57 PM Drew Fustini <drew@beagleboard.org> wrote:
>
> On Sat, Oct 31, 2020 at 4:35 PM Patrick Menschel <menschel.p@posteo.de> wrote:
> >
> > > I believe Waveshare did choose other interrupt pins.
> > > Marc used 24 25 which I also chose for a pHat I'm currently making
> > > schematics for.
> > >
> > > Try these lines in /boot/config.txt
> > >
> > > dtoverlay=mcp251xfd-spi0-0,interrupt=25
> > > dtoverlay=mcp251xfd-spi1-0,interrupt=16
> > >
> > > The waveshare overlay is strange in one point. It uses Pin 26 (instead
> > > of 18) for Chip selection but that is no chip select pin. This can work
> > > if the pin is output and luckily pulls the CE line in the right direction.
> > >
> > > https://gist.github.com/pdp7/784d0ba8b9648d20ab055747ec945225#file-2xmcp2517fd-overlay-dts-L40
> > >
> > > https://pinout.xyz/pinout/pin37_gpio26#
> > >
> > > Maybe this has something to do with Nvidia Jetson Platform.
> > >
> > > --
> > > Patrick
> > >
> >
> > Apparently Pin 26 is CE1 for SPI5, only available on Pi 4.
> >
> > https://github.com/raspberrypi/firmware/blob/master/boot/overlays/README#L2674
> >
> > --
> > Patrick
>
> Thank you!  That appears to have solved the problem:
>
> #dtoverlay=2xMCP2517FD
> pi@raspberrypi:~$ dmesg | grep -Ei can\|spi
> [    5.916785] DEBUG spi.c spi_setup(): ENTER
> [    5.917056] DEBUG spi.c spi_setup(): ENTER
> [    5.960326] DEBUG spi.c spi_setup(): ENTER
> [    6.897919] CAN device driver interface
> [    6.904530] mcp251xfd spi0.0: DEBUG mcp251xfd mcp251xfd_probe():
> devm_clk_get()
> [    6.904574] mcp251xfd spi0.0: DEBUG mcp251xfd mcp251xfd_probe(): feq=40000000
> [    6.904641] DEBUG spi.c spi_setup(): ENTER
> [    6.904658] spi_master spi0: will run message pump with realtime priority
> [    6.912009] mcp251xfd spi0.0 can0: MCP2517FD rev0.0 (-RX_INT
> +MAB_NO_WARN +CRC_REG +CRC_RX +CRC_TX +ECC -HD c:40.00MHz m:20.00MHz
> r:17.00MHz e:0.00MHz) successfully initialized.
> [    6.912613] mcp251xfd spi1.0: DEBUG mcp251xfd mcp251xfd_probe():
> devm_clk_get()
> [    6.912646] mcp251xfd spi1.0: DEBUG mcp251xfd mcp251xfd_probe(): feq=40000000
> [    6.912701] DEBUG spi.c spi_setup(): ENTER
> [    6.912719] spi_master spi1: will run message pump with realtime priority
> [    6.920067] mcp251xfd spi1.0 can1: MCP2517FD rev0.0 (-RX_INT
> +MAB_NO_WARN +CRC_REG +CRC_RX +CRC_TX +ECC -HD c:40.00MHz m:20.00MHz
> r:17.00MHz e:0.00MHz) successfully initialized.

The Waveshare CANFD hat has interrupt pin of CAN1, the second
MCP2517FD, wired up to pin 36 on the Pi connector.

I changed this in mcp251xfd-spi1-0-overlay.dts:
-                               interrupts = <24 IRQ_TYPE_LEVEL_LOW>;
+                               interrupts = <16 IRQ_TYPE_LEVEL_LOW>;

And can1 is now working too:

pi@raspberrypi:~$ dmesg | grep -Ei can\|spi
[   14.663345] CAN device driver interface
[   14.669552] spi_master spi0: will run message pump with realtime priority
[   14.677102] mcp251xfd spi0.0 can0: MCP2517FD rev0.0 (-RX_INT
+MAB_NO_WARN +CRC_REG +CRC_RX +CRC_TX +ECC -HD c:40.00MHz m:20.00MHz
r:17.00MHz e:0.00MHz) successfully initialized.
[   14.677833] spi_master spi1: will run message pump with realtime priority
[   14.682667] mcp251xfd spi1.0 can1: MCP2517FD rev0.0 (-RX_INT
+MAB_NO_WARN +CRC_REG +CRC_RX +CRC_TX +ECC -HD c:40.00MHz m:20.00MHz
r:17.00MHz e:0.00MHz) successfully initialized.
[   75.254659] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready
[   77.942514] IPv6: ADDRCONF(NETDEV_CHANGE): can1: link becomes ready

thanks,
drew

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-11-01 22:49                                                     ` Drew Fustini
@ 2020-11-02  7:25                                                       ` Marc Kleine-Budde
  0 siblings, 0 replies; 54+ messages in thread
From: Marc Kleine-Budde @ 2020-11-02  7:25 UTC (permalink / raw)
  To: Drew Fustini, Patrick Menschel; +Cc: Oliver Hartkopp, linux-can, Josh S


[-- Attachment #1.1: Type: text/plain, Size: 1626 bytes --]

On 11/1/20 11:49 PM, Drew Fustini wrote:
>>>> Try these lines in /boot/config.txt
>>>>
>>>> dtoverlay=mcp251xfd-spi0-0,interrupt=25
>>>> dtoverlay=mcp251xfd-spi1-0,interrupt=16

If you use the above lines ^^, the patching of the overlay should not be necessary:

> I changed this in mcp251xfd-spi1-0-overlay.dts:
> -                               interrupts = <24 IRQ_TYPE_LEVEL_LOW>;
> +                               interrupts = <16 IRQ_TYPE_LEVEL_LOW>;

[...]

> pi@raspberrypi:~$ dmesg | grep -Ei can\|spi
> [   14.663345] CAN device driver interface
> [   14.669552] spi_master spi0: will run message pump with realtime priority
> [   14.677102] mcp251xfd spi0.0 can0: MCP2517FD rev0.0 (-RX_INT
> +MAB_NO_WARN +CRC_REG +CRC_RX +CRC_TX +ECC -HD c:40.00MHz m:20.00MHz
> r:17.00MHz e:0.00MHz) successfully initialized.
> [   14.677833] spi_master spi1: will run message pump with realtime priority
> [   14.682667] mcp251xfd spi1.0 can1: MCP2517FD rev0.0 (-RX_INT
> +MAB_NO_WARN +CRC_REG +CRC_RX +CRC_TX +ECC -HD c:40.00MHz m:20.00MHz
> r:17.00MHz e:0.00MHz) successfully initialized.

Note: the waveshare module uses a mcp2517fd, which has some erratas. You will
experience error frames generated by sending mcp2517fd modules, during certain
conditions. Sometimes CAN frames in the RX path are dropped.

regards,
Marc

-- 
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 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-31 12:27                                             ` Drew Fustini
  2020-10-31 15:14                                               ` Patrick Menschel
@ 2020-11-02  7:26                                               ` Marc Kleine-Budde
  1 sibling, 0 replies; 54+ messages in thread
From: Marc Kleine-Budde @ 2020-11-02  7:26 UTC (permalink / raw)
  To: Drew Fustini; +Cc: Patrick Menschel, Oliver Hartkopp, linux-can, Josh S


[-- Attachment #1.1: Type: text/plain, Size: 494 bytes --]

On 10/31/20 1:27 PM, Drew Fustini wrote:
> Alright, it looks like I had faulty hardware!  I got a Waveshare CAN
> FD hat and both the old waveshare-provided driver and the new
> mcp251xfd driver work.

YEAY

Marc

-- 
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 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-31 15:14                                               ` Patrick Menschel
  2020-10-31 15:35                                                 ` Patrick Menschel
@ 2020-11-02  7:55                                                 ` Marc Kleine-Budde
  1 sibling, 0 replies; 54+ messages in thread
From: Marc Kleine-Budde @ 2020-11-02  7:55 UTC (permalink / raw)
  To: Patrick Menschel, Drew Fustini; +Cc: Oliver Hartkopp, linux-can, Josh S


[-- Attachment #1.1: Type: text/plain, Size: 941 bytes --]

On 10/31/20 4:14 PM, Patrick Menschel wrote:
[...]

> The waveshare overlay is strange in one point. It uses Pin 26 (instead
> of 18) for Chip selection but that is no chip select pin. This can work
> if the pin is output and luckily pulls the CE line in the right direction.
> 
> https://gist.github.com/pdp7/784d0ba8b9648d20ab055747ec945225#file-2xmcp2517fd-overlay-dts-L40
> 
> https://pinout.xyz/pinout/pin37_gpio26#

According to the schematics:

    https://www.waveshare.com/w/upload/e/e2/2-CH-CAN-FD-HAT-Schematic.pdf

the waveshare uses per default the CS0 and CS1 of SPI0. But you can configure
via JPAD3 it to P25, which is GPIO26.

Marc

-- 
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 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-31 21:57                                                   ` Drew Fustini
  2020-11-01 22:49                                                     ` Drew Fustini
@ 2020-11-02  8:18                                                     ` Marc Kleine-Budde
       [not found]                                                       ` <CAPgEAj7LcX3cb+syhtR1i3Uo1XkYYFQ_wDPV8GniaA-YwPk2Hg@mail.gmail.com>
  1 sibling, 1 reply; 54+ messages in thread
From: Marc Kleine-Budde @ 2020-11-02  8:18 UTC (permalink / raw)
  To: Drew Fustini, Patrick Menschel; +Cc: Oliver Hartkopp, linux-can, Josh S


[-- Attachment #1.1: Type: text/plain, Size: 1835 bytes --]

On 10/31/20 10:57 PM, Drew Fustini wrote:
> #dtoverlay=2xMCP2517FD
> pi@raspberrypi:~$ dmesg | grep -Ei can\|spi
> [    5.916785] DEBUG spi.c spi_setup(): ENTER
> [    5.917056] DEBUG spi.c spi_setup(): ENTER
> [    5.960326] DEBUG spi.c spi_setup(): ENTER
> [    6.897919] CAN device driver interface
> [    6.904530] mcp251xfd spi0.0: DEBUG mcp251xfd mcp251xfd_probe():
> devm_clk_get()
> [    6.904574] mcp251xfd spi0.0: DEBUG mcp251xfd mcp251xfd_probe(): feq=40000000
> [    6.904641] DEBUG spi.c spi_setup(): ENTER
> [    6.904658] spi_master spi0: will run message pump with realtime priority
> [    6.912009] mcp251xfd spi0.0 can0: MCP2517FD rev0.0 (-RX_INT
> +MAB_NO_WARN +CRC_REG +CRC_RX +CRC_TX +ECC -HD c:40.00MHz m:20.00MHz
> r:17.00MHz e:0.00MHz) successfully initialized.

> [    6.912613] mcp251xfd spi1.0: DEBUG mcp251xfd mcp251xfd_probe():
> devm_clk_get()
> [    6.912646] mcp251xfd spi1.0: DEBUG mcp251xfd mcp251xfd_probe(): feq=40000000
> [    6.912701] DEBUG spi.c spi_setup(): ENTER
> [    6.912719] spi_master spi1: will run message pump with realtime priority
> [    6.920067] mcp251xfd spi1.0 can1: MCP2517FD rev0.0 (-RX_INT
> +MAB_NO_WARN +CRC_REG +CRC_RX +CRC_TX +ECC -HD c:40.00MHz m:20.00MHz
> r:17.00MHz e:0.00MHz) successfully initialized.

spi1.0?

Have you changed any of the solder jumpers on JPAD3? See the 0 ohm resistors at A/B:

    https://www.waveshare.com/w/upload/1/13/2-CH_CAN_FD_HAT_Manual-3.png

I cannot see, how any of the chip selects of SPI1 is routed to the mcp2517fd....

Marc

-- 
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 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
       [not found]                                                       ` <CAPgEAj7LcX3cb+syhtR1i3Uo1XkYYFQ_wDPV8GniaA-YwPk2Hg@mail.gmail.com>
@ 2020-11-02 11:00                                                         ` Marc Kleine-Budde
       [not found]                                                           ` <CAPgEAj7BTJyiBg4QkKuekYH0zyrA-10dby3Lgb5qj2uiD4ZOYQ@mail.gmail.com>
  2020-11-02 17:34                                                           ` mcp251xfd on RPi 5.4 downstream Patrick Menschel
  0 siblings, 2 replies; 54+ messages in thread
From: Marc Kleine-Budde @ 2020-11-02 11:00 UTC (permalink / raw)
  To: Drew Fustini; +Cc: Patrick Menschel, Oliver Hartkopp, linux-can, Josh S


[-- Attachment #1.1: Type: text/plain, Size: 1208 bytes --]

On 11/2/20 11:40 AM, Drew Fustini wrote:
>     spi1.0?
> 
>     Have you changed any of the solder jumpers on JPAD3? See the 0 ohm resistors
>     at A/B:
> 
>         https://www.waveshare.com/w/upload/1/13/2-CH_CAN_FD_HAT_Manual-3.png
> 
>     I cannot see, how any of the chip selects of SPI1 is routed to the mcp2517fd....
> 

[...]

> The jumpers are in the A position so can1 is set to use spi1.

...according to the PCB-print, but not according to the schematics (at least how
I read it):

    https://www.waveshare.com/w/upload/e/e2/2-CH-CAN-FD-HAT-Schematic.pdf

Grmpf :/

> This means that can1 cs is connected to pi header pin 26 

Both of rpi's SPI host drivers prefer to use GPIO chip selects by default, as
native chip selects have some limitations. And all three mcp251xfd overlays use
GPIO chip selects, this means you can use any free GPIO in the system for the
SPI chip select.

Marc

-- 
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 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd: loopback test on waveshare canfd hat
       [not found]                                                           ` <CAPgEAj7BTJyiBg4QkKuekYH0zyrA-10dby3Lgb5qj2uiD4ZOYQ@mail.gmail.com>
@ 2020-11-02 14:22                                                             ` Marc Kleine-Budde
  2020-11-02 14:35                                                               ` Drew Fustini
  0 siblings, 1 reply; 54+ messages in thread
From: Marc Kleine-Budde @ 2020-11-02 14:22 UTC (permalink / raw)
  To: Drew Fustini; +Cc: Patrick Menschel, Oliver Hartkopp, linux-can, Josh S


[-- Attachment #1.1: Type: text/plain, Size: 851 bytes --]

On 11/2/20 3:20 PM, Drew Fustini wrote:
> I am able to have can0 (spi0.0) and can1 (spi1.0) initialize ok on the
> waveshare canfd hat (solder jumper mode A) with the mcp251xfd driver
> from Marc's rpi 5.4 branch.  However, I am not able to do a loopback
> test successfully.
> 
> No errors from setup:
> sudo ip link set can0 type can bitrate 250000 listen-only on
> sudo ip link set can1 type can bitrate 250000 listen-only on
                                                ^^^^^^^^^^^^^^

It really does listen-only on the bus, i.e. not send anything :)

Marc

-- 
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 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd: loopback test on waveshare canfd hat
  2020-11-02 14:22                                                             ` mcp251xfd: loopback test on waveshare canfd hat Marc Kleine-Budde
@ 2020-11-02 14:35                                                               ` Drew Fustini
  2020-11-02 14:38                                                                 ` Marc Kleine-Budde
  0 siblings, 1 reply; 54+ messages in thread
From: Drew Fustini @ 2020-11-02 14:35 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: Patrick Menschel, Oliver Hartkopp, linux-can, Josh S

On Mon, Nov 2, 2020 at 3:22 PM Marc Kleine-Budde <mkl@pengutronix.de> wrote:
>
> On 11/2/20 3:20 PM, Drew Fustini wrote:
> > I am able to have can0 (spi0.0) and can1 (spi1.0) initialize ok on the
> > waveshare canfd hat (solder jumper mode A) with the mcp251xfd driver
> > from Marc's rpi 5.4 branch.  However, I am not able to do a loopback
> > test successfully.
> >
> > No errors from setup:
> > sudo ip link set can0 type can bitrate 250000 listen-only on
> > sudo ip link set can1 type can bitrate 250000 listen-only on
>                                                 ^^^^^^^^^^^^^^
>
> It really does listen-only on the bus, i.e. not send anything :)
>
> Marc

Thanks for pointing that out!  /me might need new glasses :)

The can0->can1 test is now working with mcp251xfd:

pi@raspberrypi:~$ sudo ip link set can0 type can bitrate 250000
pi@raspberrypi:~$ sudo ip link set can1 type can bitrate 250000
pi@raspberrypi:~$ sudo ifconfig can0 up
pi@raspberrypi:~$ sudo ifconfig can1 up
pi@raspberrypi:~$ dmesg |tail
[   75.751015] mcp251xfd spi0.0 can0: bit-timing not yet defined
[   75.811003] mcp251xfd spi1.0 can1: bit-timing not yet defined
[   96.934271] mcp251xfd spi0.0 can0: FIFO setup: TEF: 8*12 bytes = 96
bytes, TX: 8*16 bytes = 128 bytes
[   96.934292] mcp251xfd spi0.0 can0: FIFO setup: RX-0: 32*20 bytes = 640 bytes
[   96.934308] mcp251xfd spi0.0 can0: FIFO setup: free: 1184 bytes
[   96.942154] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready
[   97.020451] mcp251xfd spi1.0 can1: FIFO setup: TEF: 8*12 bytes = 96
bytes, TX: 8*16 bytes = 128 bytes
[   97.020464] mcp251xfd spi1.0 can1: FIFO setup: RX-0: 32*20 bytes = 640 bytes
[   97.020474] mcp251xfd spi1.0 can1: FIFO setup: free: 1184 bytes
[   97.990436] IPv6: ADDRCONF(NETDEV_CHANGE): can1: link becomes ready

pi@raspberrypi:~$ candump can1 &
[1] 1037
pi@raspberrypi:~$ cansend can0 01a#11223344AABBCCDD
  can1  01A   [8]  11 22 33 44 AA BB CC DD

thanks,
drew

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd: loopback test on waveshare canfd hat
  2020-11-02 14:35                                                               ` Drew Fustini
@ 2020-11-02 14:38                                                                 ` Marc Kleine-Budde
  0 siblings, 0 replies; 54+ messages in thread
From: Marc Kleine-Budde @ 2020-11-02 14:38 UTC (permalink / raw)
  To: Drew Fustini; +Cc: Patrick Menschel, Oliver Hartkopp, linux-can, Josh S


[-- Attachment #1.1: Type: text/plain, Size: 2370 bytes --]

On 11/2/20 3:35 PM, Drew Fustini wrote:
> On Mon, Nov 2, 2020 at 3:22 PM Marc Kleine-Budde <mkl@pengutronix.de> wrote:
>>
>> On 11/2/20 3:20 PM, Drew Fustini wrote:
>>> I am able to have can0 (spi0.0) and can1 (spi1.0) initialize ok on the
>>> waveshare canfd hat (solder jumper mode A) with the mcp251xfd driver
>>> from Marc's rpi 5.4 branch.  However, I am not able to do a loopback
>>> test successfully.
>>>
>>> No errors from setup:
>>> sudo ip link set can0 type can bitrate 250000 listen-only on
>>> sudo ip link set can1 type can bitrate 250000 listen-only on
>>                                                 ^^^^^^^^^^^^^^
>>
>> It really does listen-only on the bus, i.e. not send anything :)
>>
>> Marc
> 
> Thanks for pointing that out!  /me might need new glasses :)
> 
> The can0->can1 test is now working with mcp251xfd:
> 
> pi@raspberrypi:~$ sudo ip link set can0 type can bitrate 250000
> pi@raspberrypi:~$ sudo ip link set can1 type can bitrate 250000
> pi@raspberrypi:~$ sudo ifconfig can0 up
> pi@raspberrypi:~$ sudo ifconfig can1 up
> pi@raspberrypi:~$ dmesg |tail
> [   75.751015] mcp251xfd spi0.0 can0: bit-timing not yet defined
> [   75.811003] mcp251xfd spi1.0 can1: bit-timing not yet defined
> [   96.934271] mcp251xfd spi0.0 can0: FIFO setup: TEF: 8*12 bytes = 96
> bytes, TX: 8*16 bytes = 128 bytes
> [   96.934292] mcp251xfd spi0.0 can0: FIFO setup: RX-0: 32*20 bytes = 640 bytes
> [   96.934308] mcp251xfd spi0.0 can0: FIFO setup: free: 1184 bytes
> [   96.942154] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready
> [   97.020451] mcp251xfd spi1.0 can1: FIFO setup: TEF: 8*12 bytes = 96
> bytes, TX: 8*16 bytes = 128 bytes
> [   97.020464] mcp251xfd spi1.0 can1: FIFO setup: RX-0: 32*20 bytes = 640 bytes
> [   97.020474] mcp251xfd spi1.0 can1: FIFO setup: free: 1184 bytes
> [   97.990436] IPv6: ADDRCONF(NETDEV_CHANGE): can1: link becomes ready
> 
> pi@raspberrypi:~$ candump can1 &
> [1] 1037
> pi@raspberrypi:~$ cansend can0 01a#11223344AABBCCDD
>   can1  01A   [8]  11 22 33 44 AA BB CC DD

\o/

Marc

-- 
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 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-11-02 11:00                                                         ` Marc Kleine-Budde
       [not found]                                                           ` <CAPgEAj7BTJyiBg4QkKuekYH0zyrA-10dby3Lgb5qj2uiD4ZOYQ@mail.gmail.com>
@ 2020-11-02 17:34                                                           ` Patrick Menschel
  2020-11-02 18:47                                                             ` Patrick Menschel
  1 sibling, 1 reply; 54+ messages in thread
From: Patrick Menschel @ 2020-11-02 17:34 UTC (permalink / raw)
  To: Marc Kleine-Budde, Drew Fustini; +Cc: Oliver Hartkopp, linux-can, Josh S

>     https://www.waveshare.com/w/upload/e/e2/2-CH-CAN-FD-HAT-Schematic.pdf
> 
> Grmpf :/
> 
>> This means that can1 cs is connected to pi header pin 26 
> 
> Both of rpi's SPI host drivers prefer to use GPIO chip selects by default, as
> native chip selects have some limitations. And all three mcp251xfd overlays use
> GPIO chip selects, this means you can use any free GPIO in the system for the
> SPI chip select.
> 
> Marc
> 

It took me a while to realize but those pin numbers on the PCB are
WPI := WiringPi numbers, not header pin numbers and not BCM pin numbers.

The schematics also has the WPI column in the lower left section.

https://pinout.xyz/pinout/wiringpi#

--
Patrick

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-11-02 17:34                                                           ` mcp251xfd on RPi 5.4 downstream Patrick Menschel
@ 2020-11-02 18:47                                                             ` Patrick Menschel
  2020-11-02 18:57                                                               ` Thomas.Kopp
  2020-11-05  8:07                                                               ` Marc Kleine-Budde
  0 siblings, 2 replies; 54+ messages in thread
From: Patrick Menschel @ 2020-11-02 18:47 UTC (permalink / raw)
  To: Marc Kleine-Budde, Drew Fustini; +Cc: Oliver Hartkopp, linux-can, Josh S

>>     https://www.waveshare.com/w/upload/e/e2/2-CH-CAN-FD-HAT-Schematic.pdf
>>
>> Grmpf :/
>>
>>> This means that can1 cs is connected to pi header pin 26 
>>
>> Both of rpi's SPI host drivers prefer to use GPIO chip selects by default, as
>> native chip selects have some limitations. And all three mcp251xfd overlays use
>> GPIO chip selects, this means you can use any free GPIO in the system for the
>> SPI chip select.
>>
>> Marc
>>
> 
> It took me a while to realize but those pin numbers on the PCB are
> WPI := WiringPi numbers, not header pin numbers and not BCM pin numbers.
> 
> The schematics also has the WPI column in the lower left section.
> 
> https://pinout.xyz/pinout/wiringpi#
> 
> --
> Patrick
> 

It may be a blunt guess, but according to page 99

https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2711/rpi_DATA_2711_1p0.pdf

Pin 26 is pulldown. So it works if it remains unused because the pin is
input with pulldown thus the chip is selected by default.

I don't know if the CE pin can actually work if there is no matching alt
function in pinselect register.

--
Patrick


^ permalink raw reply	[flat|nested] 54+ messages in thread

* RE: mcp251xfd on RPi 5.4 downstream
  2020-11-02 18:47                                                             ` Patrick Menschel
@ 2020-11-02 18:57                                                               ` Thomas.Kopp
  2020-11-02 19:32                                                                 ` Patrick Menschel
  2020-11-05  8:08                                                                 ` Marc Kleine-Budde
  2020-11-05  8:07                                                               ` Marc Kleine-Budde
  1 sibling, 2 replies; 54+ messages in thread
From: Thomas.Kopp @ 2020-11-02 18:57 UTC (permalink / raw)
  To: menschel.p, mkl, drew; +Cc: socketcan, linux-can, josh

> It may be a blunt guess, but according to page 99
> 
> https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm27
> 11/rpi_DATA_2711_1p0.pdf
> 
> Pin 26 is pulldown. So it works if it remains unused because the pin is
> input with pulldown thus the chip is selected by default.
> 
> I don't know if the CE pin can actually work if there is no matching alt
> function in pinselect register.
> 
> --
> Patrick
Do you suggest that the communication works with a permanent low on CS/CE?
Without the CS/CE pin having edges you will not be able to send multiple 
commands. The driver is writing/reading multiple times when bringing up the
chip. If you have a permanent low that will fail. So somehow the CS does 
generate the right edges.

Thomas

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-11-02 18:57                                                               ` Thomas.Kopp
@ 2020-11-02 19:32                                                                 ` Patrick Menschel
  2020-11-04 18:48                                                                   ` Patrick Menschel
  2020-11-05  8:08                                                                 ` Marc Kleine-Budde
  1 sibling, 1 reply; 54+ messages in thread
From: Patrick Menschel @ 2020-11-02 19:32 UTC (permalink / raw)
  To: Thomas.Kopp, mkl, drew; +Cc: socketcan, linux-can, josh

>> It may be a blunt guess, but according to page 99
>>
>> https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm27
>> 11/rpi_DATA_2711_1p0.pdf
>>
>> Pin 26 is pulldown. So it works if it remains unused because the pin is
>> input with pulldown thus the chip is selected by default.
>>
>> I don't know if the CE pin can actually work if there is no matching alt
>> function in pinselect register.
>>
>> --
>> Patrick
> Do you suggest that the communication works with a permanent low on CS/CE?
> Without the CS/CE pin having edges you will not be able to send multiple 
> commands. The driver is writing/reading multiple times when bringing up the
> chip. If you have a permanent low that will fail. So somehow the CS does 
> generate the right edges.
> 
> Thomas
> 
As mentioned it's a blunt guess. If there is more to CE functionality
then just enabling the recipient to listen, then I'm obviously wrong.

--
Patrick

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-11-02 19:32                                                                 ` Patrick Menschel
@ 2020-11-04 18:48                                                                   ` Patrick Menschel
  2020-11-05  7:15                                                                     ` Marc Kleine-Budde
  0 siblings, 1 reply; 54+ messages in thread
From: Patrick Menschel @ 2020-11-04 18:48 UTC (permalink / raw)
  To: mkl, drew; +Cc: socketcan, linux-can, josh

Hi,

I can confirm it works on a Pi 0w too.

pi@rpi-0w-1:~ $ dmesg | grep -Ei can\|spi
[   29.478369] CAN device driver interface
[   29.615519] spi_master spi0: will run message pump with realtime priority
[   29.660342] mcp251xfd spi0.0 can0: MCP2517FD rev0.0 (-RX_INT
+MAB_NO_WARN +CRC_REG +CRC_RX +CRC_TX +ECC -HD c:40.00MHz m:10.00MHz
r:10.00MHz e:0.00MHz) successfully initialized.

Its just a bread board install and I had to reduce the Spi-Max-Frequency
due to 10cm long cables. It least I believe it's the cable length.

--
Patrick

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-11-04 18:48                                                                   ` Patrick Menschel
@ 2020-11-05  7:15                                                                     ` Marc Kleine-Budde
  2020-11-05 18:11                                                                       ` Patrick Menschel
  0 siblings, 1 reply; 54+ messages in thread
From: Marc Kleine-Budde @ 2020-11-05  7:15 UTC (permalink / raw)
  To: Patrick Menschel, drew; +Cc: socketcan, linux-can, josh


[-- Attachment #1.1: Type: text/plain, Size: 949 bytes --]

On 11/4/20 7:48 PM, Patrick Menschel wrote:
> Hi,
> 
> I can confirm it works on a Pi 0w too.
> 
> pi@rpi-0w-1:~ $ dmesg | grep -Ei can\|spi
> [   29.478369] CAN device driver interface
> [   29.615519] spi_master spi0: will run message pump with realtime priority
> [   29.660342] mcp251xfd spi0.0 can0: MCP2517FD rev0.0 (-RX_INT
> +MAB_NO_WARN +CRC_REG +CRC_RX +CRC_TX +ECC -HD c:40.00MHz m:10.00MHz
> r:10.00MHz e:0.00MHz) successfully initialized.
> 
> Its just a bread board install and I had to reduce the Spi-Max-Frequency
> due to 10cm long cables. It least I believe it's the cable length.

What happens if you don't reduce the SPI frequency?

Marc

-- 
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 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-11-02 18:47                                                             ` Patrick Menschel
  2020-11-02 18:57                                                               ` Thomas.Kopp
@ 2020-11-05  8:07                                                               ` Marc Kleine-Budde
  1 sibling, 0 replies; 54+ messages in thread
From: Marc Kleine-Budde @ 2020-11-05  8:07 UTC (permalink / raw)
  To: Patrick Menschel, Drew Fustini; +Cc: Oliver Hartkopp, linux-can, Josh S


[-- Attachment #1.1: Type: text/plain, Size: 1654 bytes --]

On 11/2/20 7:47 PM, Patrick Menschel wrote:
>>>     https://www.waveshare.com/w/upload/e/e2/2-CH-CAN-FD-HAT-Schematic.pdf
>>>
>>> Grmpf :/
>>>
>>>> This means that can1 cs is connected to pi header pin 26 
>>>
>>> Both of rpi's SPI host drivers prefer to use GPIO chip selects by default, as
>>> native chip selects have some limitations. And all three mcp251xfd overlays use
>>> GPIO chip selects, this means you can use any free GPIO in the system for the
>>> SPI chip select.
>>>
>>> Marc
>>>
>>
>> It took me a while to realize but those pin numbers on the PCB are
>> WPI := WiringPi numbers, not header pin numbers and not BCM pin numbers.
>>
>> The schematics also has the WPI column in the lower left section.
>>
>> https://pinout.xyz/pinout/wiringpi#
>>
>> --
>> Patrick
>>
> 
> It may be a blunt guess, but according to page 99
> 
> https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2711/rpi_DATA_2711_1p0.pdf
> 
> Pin 26 is pulldown. So it works if it remains unused because the pin is
> input with pulldown thus the chip is selected by default.
> 
> I don't know if the CE pin can actually work if there is no matching alt
> function in pinselect register.

Both rpi SPI drivers don't use native chip selects, they use GPIOs. This means
you can use any gpio as chip select.

This is why this setup works.

Marc

-- 
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 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-11-02 18:57                                                               ` Thomas.Kopp
  2020-11-02 19:32                                                                 ` Patrick Menschel
@ 2020-11-05  8:08                                                                 ` Marc Kleine-Budde
  1 sibling, 0 replies; 54+ messages in thread
From: Marc Kleine-Budde @ 2020-11-05  8:08 UTC (permalink / raw)
  To: Thomas.Kopp, menschel.p, drew; +Cc: socketcan, linux-can, josh


[-- Attachment #1.1: Type: text/plain, Size: 1189 bytes --]

On 11/2/20 7:57 PM, Thomas.Kopp@microchip.com wrote:
>> It may be a blunt guess, but according to page 99
>>
>> https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm27
>> 11/rpi_DATA_2711_1p0.pdf
>>
>> Pin 26 is pulldown. So it works if it remains unused because the pin is
>> input with pulldown thus the chip is selected by default.
>>
>> I don't know if the CE pin can actually work if there is no matching alt
>> function in pinselect register.

> Do you suggest that the communication works with a permanent low on CS/CE?

No.

> Without the CS/CE pin having edges you will not be able to send multiple 
> commands. The driver is writing/reading multiple times when bringing up the
> chip. If you have a permanent low that will fail. So somehow the CS does 
> generate the right edges.

The overlay configures the Pin for gpio and the SPI driver uses it in GPIO mode.

Marc

-- 
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 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-11-05  7:15                                                                     ` Marc Kleine-Budde
@ 2020-11-05 18:11                                                                       ` Patrick Menschel
  2020-11-06  9:00                                                                         ` Marc Kleine-Budde
  0 siblings, 1 reply; 54+ messages in thread
From: Patrick Menschel @ 2020-11-05 18:11 UTC (permalink / raw)
  To: Marc Kleine-Budde, drew; +Cc: socketcan, linux-can, josh

>> Its just a bread board install and I had to reduce the Spi-Max-Frequency
>> due to 10cm long cables. It least I believe it's the cable length.
> 
> What happens if you don't reduce the SPI frequency?

CRC Errors above 16Mhz spi frequency.

## No limit
$ dmesg | grep -Ei can\|spi
[   30.006596] CAN device driver interface
[   30.276213] spi_master spi0: will run message pump with realtime priority
[   30.436807] mcp251xfd spi0.0 (unnamed net_device) (uninitialized):
CRC read error at address 0x0000 (length=4, data=00 07 18 04, CRC=0xb29d).
[   30.436835] mcp251xfd spi0.0 (unnamed net_device) (uninitialized):
Controller failed to enter mode Configuration Mode (4) and stays in
Internal Loopback Mode (2).
[   30.437036] mcp251xfd spi0.0 (unnamed net_device) (uninitialized):
CRC read error at address 0x0000 (length=4, data=00 07 18 04, CRC=0xb29d).
[   30.437261] mcp251xfd: probe of spi0.0 failed with error -74

## 18Mhz
$ dmesg | grep -Ei can\|spi
[   30.345967] CAN device driver interface
[   30.503372] spi_master spi0: will run message pump with realtime priority
[   30.542854] mcp251xfd spi0.0 (unnamed net_device) (uninitialized):
CRC read error at address 0x0000 (length=4, data=60 07 18 04, CRC=0xb28c).
[   30.543057] mcp251xfd spi0.0 (unnamed net_device) (uninitialized):
CRC read error at address 0x0000 (length=4, data=60 07 18 04, CRC=0xb28c).
[   30.543286] mcp251xfd: probe of spi0.0 failed with error -74

## 16Mhz
$ dmesg | grep -Ei can\|spi
[   29.496863] CAN device driver interface
[   30.028215] spi_master spi0: will run message pump with realtime priority
[   30.171532] mcp251xfd spi0.0 can0: MCP2517FD rev0.0 (-RX_INT
+MAB_NO_WARN +CRC_REG +CRC_RX +CRC_TX +ECC -HD c:40.00MHz m:16.00MHz
r:16.00MHz e:0.00MHz) successfully initialized.


--
Patrick

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-11-05 18:11                                                                       ` Patrick Menschel
@ 2020-11-06  9:00                                                                         ` Marc Kleine-Budde
  2020-11-06 11:31                                                                           ` Patrick Menschel
  0 siblings, 1 reply; 54+ messages in thread
From: Marc Kleine-Budde @ 2020-11-06  9:00 UTC (permalink / raw)
  To: Patrick Menschel, drew; +Cc: socketcan, linux-can, josh


[-- Attachment #1.1: Type: text/plain, Size: 620 bytes --]

On 11/5/20 7:11 PM, Patrick Menschel wrote:
>>> Its just a bread board install and I had to reduce the Spi-Max-Frequency
>>> due to 10cm long cables. It least I believe it's the cable length.
>>
>> What happens if you don't reduce the SPI frequency?
> 
> CRC Errors above 16Mhz spi frequency.

Ok - Which SoC are you using? rpi4?

Marc

-- 
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 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-11-06  9:00                                                                         ` Marc Kleine-Budde
@ 2020-11-06 11:31                                                                           ` Patrick Menschel
  2020-11-06 11:36                                                                             ` Marc Kleine-Budde
  0 siblings, 1 reply; 54+ messages in thread
From: Patrick Menschel @ 2020-11-06 11:31 UTC (permalink / raw)
  To: Marc Kleine-Budde, drew; +Cc: socketcan, linux-can, josh

> On 11/5/20 7:11 PM, Patrick Menschel wrote:
>>>> Its just a bread board install and I had to reduce the Spi-Max-Frequency
>>>> due to 10cm long cables. It least I believe it's the cable length.
>>>
>>> What happens if you don't reduce the SPI frequency?
>>
>> CRC Errors above 16Mhz spi frequency.
> 
> Ok - Which SoC are you using? rpi4?
> 
> Marc
> 

https://www.raspberrypi.org/products/raspberry-pi-zero-w/

--
Patrick

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-11-06 11:31                                                                           ` Patrick Menschel
@ 2020-11-06 11:36                                                                             ` Marc Kleine-Budde
  2020-11-06 11:46                                                                               ` Patrick Menschel
  0 siblings, 1 reply; 54+ messages in thread
From: Marc Kleine-Budde @ 2020-11-06 11:36 UTC (permalink / raw)
  To: Patrick Menschel, drew; +Cc: socketcan, linux-can, josh


[-- Attachment #1.1: Type: text/plain, Size: 794 bytes --]

On 11/6/20 12:31 PM, Patrick Menschel wrote:
>> On 11/5/20 7:11 PM, Patrick Menschel wrote:
>>>>> Its just a bread board install and I had to reduce the Spi-Max-Frequency
>>>>> due to 10cm long cables. It least I believe it's the cable length.
>>>>
>>>> What happens if you don't reduce the SPI frequency?
>>>
>>> CRC Errors above 16Mhz spi frequency.
>>
>> Ok - Which SoC are you using? rpi4?
>>
>> Marc
>>
> 
> https://www.raspberrypi.org/products/raspberry-pi-zero-w/

any config.txt options?

Marc

-- 
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 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-11-06 11:36                                                                             ` Marc Kleine-Budde
@ 2020-11-06 11:46                                                                               ` Patrick Menschel
  0 siblings, 0 replies; 54+ messages in thread
From: Patrick Menschel @ 2020-11-06 11:46 UTC (permalink / raw)
  To: Marc Kleine-Budde, drew; +Cc: socketcan, linux-can, josh

> On 11/6/20 12:31 PM, Patrick Menschel wrote:
>>> On 11/5/20 7:11 PM, Patrick Menschel wrote:
>>>>>> Its just a bread board install and I had to reduce the Spi-Max-Frequency
>>>>>> due to 10cm long cables. It least I believe it's the cable length.
>>>>>
>>>>> What happens if you don't reduce the SPI frequency?
>>>>
>>>> CRC Errors above 16Mhz spi frequency.
>>>
>>> Ok - Which SoC are you using? rpi4?
>>>
>>> Marc
>>>
>>
>> https://www.raspberrypi.org/products/raspberry-pi-zero-w/
> 
> any config.txt options?
> 
> Marc
> 

Just the standard stuff,

enabled peripherals

dtparam=i2c_arm=on
dtparam=spi=on

disabled wifi and bt

dtoverlay=disable-wifi
dtoverlay=disable-bt

enabled CAN

dtoverlay=mcp251xfd-spi0-0,spimaxfrequency=16000000


--
Patrick

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
  2020-10-22  3:10 mcp251xfd on RPi 5.4 downstream Drew Fustini
  2020-10-22  6:00 ` Drew Fustini
@ 2020-11-20 12:32 ` Marc Kleine-Budde
       [not found]   ` <CAEf4M_B68X2T0rkaq0tqahBFPc+Gbvac7-+G0j5jd-g4j+j01g@mail.gmail.com>
  1 sibling, 1 reply; 54+ messages in thread
From: Marc Kleine-Budde @ 2020-11-20 12:32 UTC (permalink / raw)
  To: Drew Fustini, linux-can; +Cc: Josh S


[-- Attachment #1.1: Type: text/plain, Size: 892 bytes --]

On 10/22/20 5:10 AM, Drew Fustini wrote:
> Hi Marc, thanks for working on mcp251xfd driver that has been pulled into 5.10.

FYI:

the driver including the overlays are now in the v5.4 rpi kernel. Also the v5.10
rpi kernel has the overlays.

Note: It's only one overlay that can be used multiple times, here for a
mcp251xfd on spi0/cs0 and one one spi0/cs1:

> dtoverlay=mcp251xfd,spi0-0,interrupt=25,rx_interrupt=27
> dtoverlay=mcp251xfd,spi0-1,interrupt=5,rx_interrupt=13

For devices on spi1 or spi2, the interfaces should be enabled with one of the
spi1-1/2/3cs and/or spi2-1/2/3cs overlays.

Marc

-- 
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 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: mcp251xfd on RPi 5.4 downstream
       [not found]   ` <CAEf4M_B68X2T0rkaq0tqahBFPc+Gbvac7-+G0j5jd-g4j+j01g@mail.gmail.com>
@ 2020-11-20 13:16     ` Marc Kleine-Budde
  0 siblings, 0 replies; 54+ messages in thread
From: Marc Kleine-Budde @ 2020-11-20 13:16 UTC (permalink / raw)
  To: Drew Fustini; +Cc: Drew Fustini, linux-can, Josh S


[-- Attachment #1.1: Type: text/plain, Size: 953 bytes --]

On 11/20/20 2:09 PM, Drew Fustini wrote:
>     Note: It's only one overlay that can be used multiple times, here for a
>     mcp251xfd on spi0/cs0 and one one spi0/cs1:
> 
>     > dtoverlay=mcp251xfd,spi0-0,interrupt=25,rx_interrupt=27
>     > dtoverlay=mcp251xfd,spi0-1,interrupt=5,rx_interrupt=13
> 
>     For devices on spi1 or spi2, the interfaces should be enabled with one of the
>     spi1-1/2/3cs and/or spi2-1/2/3cs overlays.
> 
> Is it possible to specify gpio pin for CS in dtoverlay?

Let me see....Untested example though :D

enable spi1 with 2 chip selects, use pin 23 for CS0 and pin 42 for CS1:

| dtoverlay=spi1-2cs,cs0_pin=23,cs1_pin=42

Marc

-- 
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 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 54+ messages in thread

end of thread, other threads:[~2020-11-20 13:16 UTC | newest]

Thread overview: 54+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-22  3:10 mcp251xfd on RPi 5.4 downstream Drew Fustini
2020-10-22  6:00 ` Drew Fustini
2020-10-22  6:33   ` Marc Kleine-Budde
2020-10-22 18:42     ` Drew Fustini
2020-10-25  4:30       ` Drew Fustini
2020-10-25  8:49         ` Oliver Hartkopp
2020-10-25 10:58           ` Marc Kleine-Budde
2020-10-25 17:43             ` Patrick Menschel
2020-10-25 18:14               ` Marc Kleine-Budde
2020-10-25 18:42                 ` Patrick Menschel
2020-10-26  1:59                   ` Drew Fustini
2020-10-26  2:50                     ` Drew Fustini
2020-10-26  5:16                       ` Patrick Menschel
2020-10-26  7:45                         ` Marc Kleine-Budde
2020-10-26  9:40                       ` Marc Kleine-Budde
2020-10-26 16:51                         ` Patrick Menschel
2020-10-26 17:00                           ` Marc Kleine-Budde
2020-10-27  2:22                             ` Drew Fustini
2020-10-27  6:35                               ` Drew Fustini
2020-10-27  7:06                                 ` Marc Kleine-Budde
2020-10-27 18:18                                   ` Patrick Menschel
2020-10-27 18:22                                     ` Marc Kleine-Budde
2020-10-28  1:57                                       ` Drew Fustini
2020-10-28  3:47                                         ` Drew Fustini
2020-10-28  7:57                                           ` Marc Kleine-Budde
2020-10-31 12:27                                             ` Drew Fustini
2020-10-31 15:14                                               ` Patrick Menschel
2020-10-31 15:35                                                 ` Patrick Menschel
2020-10-31 21:57                                                   ` Drew Fustini
2020-11-01 22:49                                                     ` Drew Fustini
2020-11-02  7:25                                                       ` Marc Kleine-Budde
2020-11-02  8:18                                                     ` Marc Kleine-Budde
     [not found]                                                       ` <CAPgEAj7LcX3cb+syhtR1i3Uo1XkYYFQ_wDPV8GniaA-YwPk2Hg@mail.gmail.com>
2020-11-02 11:00                                                         ` Marc Kleine-Budde
     [not found]                                                           ` <CAPgEAj7BTJyiBg4QkKuekYH0zyrA-10dby3Lgb5qj2uiD4ZOYQ@mail.gmail.com>
2020-11-02 14:22                                                             ` mcp251xfd: loopback test on waveshare canfd hat Marc Kleine-Budde
2020-11-02 14:35                                                               ` Drew Fustini
2020-11-02 14:38                                                                 ` Marc Kleine-Budde
2020-11-02 17:34                                                           ` mcp251xfd on RPi 5.4 downstream Patrick Menschel
2020-11-02 18:47                                                             ` Patrick Menschel
2020-11-02 18:57                                                               ` Thomas.Kopp
2020-11-02 19:32                                                                 ` Patrick Menschel
2020-11-04 18:48                                                                   ` Patrick Menschel
2020-11-05  7:15                                                                     ` Marc Kleine-Budde
2020-11-05 18:11                                                                       ` Patrick Menschel
2020-11-06  9:00                                                                         ` Marc Kleine-Budde
2020-11-06 11:31                                                                           ` Patrick Menschel
2020-11-06 11:36                                                                             ` Marc Kleine-Budde
2020-11-06 11:46                                                                               ` Patrick Menschel
2020-11-05  8:08                                                                 ` Marc Kleine-Budde
2020-11-05  8:07                                                               ` Marc Kleine-Budde
2020-11-02  7:55                                                 ` Marc Kleine-Budde
2020-11-02  7:26                                               ` Marc Kleine-Budde
2020-10-26  7:43                     ` Marc Kleine-Budde
2020-11-20 12:32 ` Marc Kleine-Budde
     [not found]   ` <CAEf4M_B68X2T0rkaq0tqahBFPc+Gbvac7-+G0j5jd-g4j+j01g@mail.gmail.com>
2020-11-20 13:16     ` Marc Kleine-Budde

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.