On do, 24 sep 2020 08:50:45 +0200, Marc Kleine-Budde wrote: > On 9/23/20 9:05 PM, Kurt Van Dijck wrote: > > On wo, 23 sep 2020 16:55:13 +0200, Matthias Weißer wrote: > >> Hi > >> > >> I currently try to get a MCP2518FD to work on our custom iMX6ULL based > >> hardware. I use the driver currently in linux-can-next backported to > >> our v5.4 kernel > >> > >> DT: > >> can0: can@0 { > >> compatible = "microchip,mcp25xxfd"; > >> reg = <0>; > >> clocks = <&can3_osc>; > >> spi-max-frequency = <85000000>; > > > I did not experience issues by using the real 20MHz upper limit here. > > Not quite... Well, the driver calculated things correctly, and it chose some 8.xx MHz to use. I didn't need to limit the spi-max-frequency manually. > > >> interrupts-extended = <&gpio1 18 IRQ_TYPE_LEVEL_LOW>; > >> status = "okay"; > >> }; > >> > >> # dmesg | grep mcp > >> [ 3.706085] mcp25xxfd spi1.0 can0: MCP2518FD rev0.0 (-RX_INT > >> -MAB_NO_WARN +CRC_REG +CRC_RX +CRC_TX +ECC -HD c:20.00MHz m:8.50MHz > >> r:8.50MHz e:0.00MHz) successfully initialized. > > > > off-topic: > > Variscite deploys a 20HHz oscillator, which brings the max spi frequency > > down to +/- 8.5MHz. > > After discussion with Thomas Kopp, I learned that microchip uses a 40MHz > > oscillator, to arrive (close to) 20MHz spi freq. > > Would you not use a 40MHz oscillator too? > > According to the debug output the can3_osc is 20 MHz. According to the datasheet > this makes 10 MHz SPI clock, however it turns out, you can only use 85% of that > to avoid stability problems. The driver takes care of the 85%, so you don't have > to specify this in the DT. I would have liked if Variscite had better investigated how to provide the best performance using the chip. Instead, someone read '20MHz max spi frequency', and put a 20MHz oscillator on the board. Since Matthias uses 'custom iMX6ULL based hardware', I assumed they made the same mistake. my point here was that they could supply a 40MHz clock, and the driver would then derive the spi max frequency to 0.85*20MHz = 17MHz. Things goes twice as fast then. > > 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 | >