qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Ben Dooks <ben.dooks@codethink.co.uk>
To: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Cc: qemu-devel@nongnu.org, jasowang@redhat.com,
	fnu.vikram@xilinx.com, nazar.kazakov@codethink.co.uk,
	lawrence.hunter@codethink.co.uk, frank.chang@sifive.com,
	paul.walmsley@sifive.com, Ben Dooks <ben.dooks@sifive.com>
Subject: Re: [PATCH v2] hw/net/can: Add mcp25625 model
Date: Tue, 21 Mar 2023 10:49:15 +0000	[thread overview]
Message-ID: <e37a42ad-dcb9-05f1-7541-8fe861bfcc79@codethink.co.uk> (raw)
In-Reply-To: <202303171511.00937.pisa@cmp.felk.cvut.cz>

On 17/03/2023 14:11, Pavel Pisa wrote:
> Hello Ben,
> 
> thanks for update.
> 
> On Thursday 16 of March 2023 13:41:13 Ben Dooks wrote:
>> From: Ben Dooks <ben.dooks@sifive.com>
>>
>> Add support for Microchip MCP25625 SPI based CAN controller which is
>> very similar to the MCP2515 (and covered by the same Linux driver).
>>
>> This can be added to any machine with SPI support in the machine
>> model file.
>>
>> Example for using this when configured into a machine:
>>
>> 	-object can-bus,id=canbus0 \
>> 	-object can-host-socketcan,id=canhost0,if=vcan0,canbus=canbus0 \
>> 	-global driver=mcp25625,property=canbus,value=canbus0
>>
>> There is tracing support with --trace "*mcp25*"
> 
> Code looks good, I have patched actual QEMU sources and build
> it successfully with your change.
> 
> I have not seen any warning.
> 
> I would like to test the mcp25625 CAN functionality.
> 
> I would prefer against some target which is already available
> in QEMU and Linux kernel mainlines, so if somebody can suggest
> some ARM which can connect SPI/SSI device it would be great.
> 
> I have setup /srv/nfs/debian-riscv64 chroot and used
> it to prepare minimal 3 MB ramdisk.cpio with busybox
> and full GLIBC and ip package.
> 
> I can run it with Debian provided RISC-V kernel
> under QEMU compiled with your mcp25625 chip emulation
> 
> qemu-system-riscv64 -m 1G -M sifive_u -smp 2 \
>        -initrd ramdisk.cpio \
>        -kernel vmlinux-6.1.0-6-riscv64 \
>        -nographic \
>        -object can-bus,id=canbus0 \
>        -object can-host-socketcan,id=canhost0,if=can0,canbus=canbus0 \
>        -global driver=mcp25625,property=canbus,value=canbus0
> 
> I can see
> 
> /sys/bus/platform/devices/10040000.spi
> /sys/bus/platform/devices/10050000.spi
> 
> I can run
> 
>    modprobe spi-sifive.ko
> 
> [   41.524160] sifive_spi 10040000.spi: mapped; irq=21, cs=1
> [   41.529305] sifive_spi 10050000.spi: mapped; irq=22, cs=1
> 
>    modprobe mcp251x.ko
> 
> I can imagine to build device tree overlay and setup it from within
> kernel if the device is already mapped
> 
>    cd /sys/kernel/config/device-tree/overlays
>    [ -d  sifive_u-mcp25625 ] && rmdir sifive_u-mcp25625
>    mkdir sifive_u-mcp25625
>    cd sifive_u-mcp25625
>    cat sifive_u-mcp25625.dtbo >dtbo
>    echo 1 >status
> 
> which is what we do with CTU CAN FD ip on Zynq system
> to run PL/FPGA update.
> 
> But from QEMU info qtree, I see that device is not mapped in QEMU...
> Which is logic...
> 
> So please, can you send instruction how to proceed forward.
> 
> Do you have DTB prepared for testing or something similar?
> 
> In a longer term perspective, it would be ideal to provide
> some update for documentation, how to use mcp25625 emulation
> 
>    https://www.qemu.org/docs/master/system/devices/can.html
> 
> By the way, if the Raspberry Pi emulation does not provide
> right SPI emulation as you have noticed, what about BeagleBoneBlack?

At the moment it seems that the as a whole qemu doesn't have a good
way of adding a generic spi device to a bus.

> Does it support SPI? It could be good target to test that mcp25625
> chip emulation is portable..

I've pushed our test branch out to:
https://gitlab.com/CodethinkLabs/qemu/-/commits/mcp25625_test

That adds an spi channel to the sifive_u machine and puts the
right dtb entry in there.

-- 
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

https://www.codethink.co.uk/privacy.html



  reply	other threads:[~2023-03-21 10:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-16 12:41 [PATCH v2] hw/net/can: Add mcp25625 model Ben Dooks
2023-03-17 14:11 ` Pavel Pisa
2023-03-21 10:49   ` Ben Dooks [this message]
2023-03-27 22:26     ` Pavel Pisa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e37a42ad-dcb9-05f1-7541-8fe861bfcc79@codethink.co.uk \
    --to=ben.dooks@codethink.co.uk \
    --cc=ben.dooks@sifive.com \
    --cc=fnu.vikram@xilinx.com \
    --cc=frank.chang@sifive.com \
    --cc=jasowang@redhat.com \
    --cc=lawrence.hunter@codethink.co.uk \
    --cc=nazar.kazakov@codethink.co.uk \
    --cc=paul.walmsley@sifive.com \
    --cc=pisa@cmp.felk.cvut.cz \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).