* how CAN-bus Linux driver MCP251x.c works
@ 2011-01-14 14:23 cheng chen
2011-01-14 15:28 ` Dave Hylands
0 siblings, 1 reply; 5+ messages in thread
From: cheng chen @ 2011-01-14 14:23 UTC (permalink / raw)
To: kernelnewbies
I am studying CAN-bus chip Linux driver, MCP251x.c in the kernel source.
However, I find a little confused about how this driver works, it registers
itself as a SPI slave device using the structure
struct spi_driver mcp2510_can_driver = {
.driver = {...}
.probe=
...
}
In probe function, it registers itself as a "net_device" with
"mcp251x_netdev_ops". So I am not sure how this system works.
I know that the userspace must see it as a network driver. But can userspace
really see this driver? Or what it can see is the module "can.ko" -- the
protocol stack ?
Does the network stack talks to SPI and SPI talks to mcp2510 chip and
transmit messages can-bus? Or something else?
Thanks
--
Cheng(?)
My Page: http://freakrobot.blogbus.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110114/4ae80cd0/attachment.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* how CAN-bus Linux driver MCP251x.c works
2011-01-14 14:23 how CAN-bus Linux driver MCP251x.c works cheng chen
@ 2011-01-14 15:28 ` Dave Hylands
2011-01-14 16:31 ` cheng chen
0 siblings, 1 reply; 5+ messages in thread
From: Dave Hylands @ 2011-01-14 15:28 UTC (permalink / raw)
To: kernelnewbies
Hi Cheng,
On Fri, Jan 14, 2011 at 6:23 AM, cheng chen <freakrobot@acm.org> wrote:
> I am studying CAN-bus chip Linux driver, MCP251x.c in the kernel source.
> However, I find a little confused about how this driver works, it registers
> itself as a SPI slave device using the structure
> struct spi_driver ?mcp2510_can_driver = {
> ?? ?.driver = {...}
> ?? ?.probe=
> ?? ?...
> }
> In probe function, it registers itself as a "net_device" with
> "mcp251x_netdev_ops". So I am not sure how this system works.
> I know that the userspace must see it as a network driver. But can userspace
> really see this driver? Or what it can see is the module "can.ko" -- the
> protocol stack ?
> Does the network stack talks to SPI and SPI talks to mcp2510 chip and
> transmit messages can-bus? Or something else?
I haven't looked at the code but I have looked at the chip, and I've
been sort of following along on the Socket-CAN list.
https://lists.berlios.de/mailman/listinfo/socketcan-users
It would register itself with the network stack, and the network stack
will expect to send and receive packets. The CAN driver then needs to
send these packets to the chip over a SPI bus. So it uses the SPI
infrastructure to send these packets to the actual MCP2510.
Every system has different SPI devices, so this way, the MCP2510
driver doesn't have to know how the actual SPI layer works, it just
knows it needs to use the SPI protocol to talk to the MCP2510.
>From userspace, you would use the socket API to send you data to
whatever device you're communicating with via CAN.
So the whole thing should go together something like this:
user space talks to socket API
network driver talks to CAN driver
CAN driver talks to SPI driver
SPI driver talks to SPI hardware
messages go over the SPI bus to MCP2510
MCP2510 sends messages over the CAN bus to the actual device
Dave Hylands
^ permalink raw reply [flat|nested] 5+ messages in thread
* how CAN-bus Linux driver MCP251x.c works
2011-01-14 15:28 ` Dave Hylands
@ 2011-01-14 16:31 ` cheng chen
2011-01-14 19:26 ` Dave Hylands
0 siblings, 1 reply; 5+ messages in thread
From: cheng chen @ 2011-01-14 16:31 UTC (permalink / raw)
To: kernelnewbies
On Fri, Jan 14, 2011 at 11:28 PM, Dave Hylands <dhylands@gmail.com> wrote:
> Hi Cheng,
>
> On Fri, Jan 14, 2011 at 6:23 AM, cheng chen <freakrobot@acm.org> wrote:
> > I am studying CAN-bus chip Linux driver, MCP251x.c in the kernel source.
> > However, I find a little confused about how this driver works, it
> registers
> > itself as a SPI slave device using the structure
> > struct spi_driver mcp2510_can_driver = {
> > .driver = {...}
> > .probe=
> > ...
> > }
> > In probe function, it registers itself as a "net_device" with
> > "mcp251x_netdev_ops". So I am not sure how this system works.
> > I know that the userspace must see it as a network driver. But can
> userspace
> > really see this driver? Or what it can see is the module "can.ko" -- the
> > protocol stack ?
> > Does the network stack talks to SPI and SPI talks to mcp2510 chip and
> > transmit messages can-bus? Or something else?
>
> I haven't looked at the code but I have looked at the chip, and I've
> been sort of following along on the Socket-CAN list.
> https://lists.berlios.de/mailman/listinfo/socketcan-users
>
> It would register itself with the network stack, and the network stack
> will expect to send and receive packets. The CAN driver then needs to
> send these packets to the chip over a SPI bus. So it uses the SPI
> infrastructure to send these packets to the actual MCP2510.
>
> Every system has different SPI devices, so this way, the MCP2510
> driver doesn't have to know how the actual SPI layer works, it just
> knows it needs to use the SPI protocol to talk to the MCP2510.
>
> From userspace, you would use the socket API to send you data to
> whatever device you're communicating with via CAN.
>
> So the whole thing should go together something like this:
>
> user space talks to socket API
> network driver talks to CAN driver
> CAN driver talks to SPI driver
> SPI driver talks to SPI hardware
> messages go over the SPI bus to MCP2510
> MCP2510 sends messages over the CAN bus to the actual device
>
> Dave Hylands
>
Thanks for your help, I understand the frameworks now.
But if I want to make the CAN driver(mcp251x.c) works on my own embedded
board, should do some work to make the SPI fit my hardware?
--
Cheng(?)
Fedora Project Contributor -- Ambassador
https://fedoraproject.org/wiki/User:Freakrobot
_______________________________________________
My Page: http://freakrobot.blogbus.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110115/1b5d01d0/attachment-0001.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* how CAN-bus Linux driver MCP251x.c works
2011-01-14 16:31 ` cheng chen
@ 2011-01-14 19:26 ` Dave Hylands
2011-01-15 7:31 ` cheng chen
0 siblings, 1 reply; 5+ messages in thread
From: Dave Hylands @ 2011-01-14 19:26 UTC (permalink / raw)
To: kernelnewbies
Hi Cheng,
On Fri, Jan 14, 2011 at 8:31 AM, cheng chen <freakrobot@acm.org> wrote:
...snip...
> Thanks for your help, I understand the frameworks now.
> But if I want to make the CAN driver(mcp251x.c) works on my own embedded
> board, should do some work to make the SPI fit my hardware?
You would need to implement the SPI driver using the SPI
infrastructure so that the CAN driver can use it.
See Documentation/spi directory for documentation on the SPI infrastructure.
Dave Hylands
^ permalink raw reply [flat|nested] 5+ messages in thread
* how CAN-bus Linux driver MCP251x.c works
2011-01-14 19:26 ` Dave Hylands
@ 2011-01-15 7:31 ` cheng chen
0 siblings, 0 replies; 5+ messages in thread
From: cheng chen @ 2011-01-15 7:31 UTC (permalink / raw)
To: kernelnewbies
Thanks very much.
On Sat, Jan 15, 2011 at 3:26 AM, Dave Hylands <dhylands@gmail.com> wrote:
> Hi Cheng,
>
> On Fri, Jan 14, 2011 at 8:31 AM, cheng chen <freakrobot@acm.org> wrote:
> ...snip...
> > Thanks for your help, I understand the frameworks now.
> > But if I want to make the CAN driver(mcp251x.c) works on my own embedded
> > board, should do some work to make the SPI fit my hardware?
>
> You would need to implement the SPI driver using the SPI
> infrastructure so that the CAN driver can use it.
>
> See Documentation/spi directory for documentation on the SPI
> infrastructure.
>
> Dave Hylands
>
--
Cheng(?)
Fedora Project Contributor -- Ambassador
https://fedoraproject.org/wiki/User:Freakrobot
_______________________________________________
My Page: http://freakrobot.blogbus.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110115/aa37f74f/attachment.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-01-15 7:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-14 14:23 how CAN-bus Linux driver MCP251x.c works cheng chen
2011-01-14 15:28 ` Dave Hylands
2011-01-14 16:31 ` cheng chen
2011-01-14 19:26 ` Dave Hylands
2011-01-15 7:31 ` cheng chen
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).