Friday, June 21, 2013

MCP2210 Linux Driver

Hello World,

Hah! I've always wanted to do that.  So I'm developing a Linux driver for the MCP2210 USB-to-SPI bridge based loosely off of Mathew King's demo driver.  Currently, it will send & receive responses for most control messages (chip settings, SPI settings, etc.), user EEPROM reads & writes and SPI messages.  However, aside from SPI messages, there is currently no interface for these (outside of hacking the driver).  SPI devices are exposed via the driver of your specification, of which I've only tested spidev, but the configuration is still hard-coded (with a fake_config() function). The plan is to expose the remaining functionality via ioctls or some such.

Without knowing the board wiring in advance, auto-configuration of SPI devices is impossible.  The MCP2210 can be configured with a start-up configuration that specifies what each pin is used for, but can only store the complete communication settings for one SPI device.  However, it offers 256 bytes of user EEPROM that is perfect for just such a thing.  Thus, I have cobbled together an auto-configuration scheme which I dub Creek -- because if it doesn't work, you're up one.  This is a simple bit-frigging mechanism that tosses unimportant precision on values and allows you to store the complete SPI config (minus protocol driver name, etc.) in under 5 bytes. As an alternative, I will provide some type of configuration ability from userland via ioctls.

I don't have this code posted anywhere just yet, but I should have it to that point by the end of June or early July and will also be submitting to LKML for initial review (and having it torn to pieces, most likely) in roughly the same time-frame.

1 comment:

  1. Update: I've published the driver & userspace utility program at https://github.com/daniel-santos/mcp2210-linux. Please note that it is still beta, but seems to be working well at this time. Please post bug reports via github's issue tracker. I'll post another blog entry about this soon.

    ReplyDelete