Results 1 to 3 of 3
Hi folks,
I am new to Linux driver development. I am in the process of adding SPI driver support to an existing driver.
A driver, supplied by a vendor, is ...
- 03-20-2009 #1Just Joined!
- Join Date
- Mar 2009
- Location
- Nashua, NH
- Posts
- 3
question about adding SPI driver support
Hi folks,
I am new to Linux driver development. I am in the process of adding SPI driver support to an existing driver.
A driver, supplied by a vendor, is a network (MAC/PHY) driver. It abstracts the specific interface to the actual MAC/PHY chip since the vendor sells several versions of the chip; i.e.: a SPI version and a parallel bus version. We are using the SPI version.
Their driver does almost everything its supposed to do Ethernet-wise, but does not do anything SPI-wise.
I need to add, to the existing driver, SPI support. I've read a lot about the mechanics of registering a driver, probe, init, etc.
Can you register a driver (such as SPI) from within another driver?
Is the following legal?
status = spi_register_driver(&ks8851_spi_driver);
if (status)
return ENOMEM;
The SPI controller is already instantiated/configured (is that the correct wording?) in our ..../mach-board/board-xxxx.c file
.
.
{ /*Ether controller */
.modalias = "ksz8851snl", // Micrel
.chip_select = 2,
.max_speed_hz = 20 * 1000 * 1000, // Micrel
.bus_num = 0,
.irq = AT91_PIN_PA0,
.mode = ((0x3 << 16) & (0xff << 16))| ((0x1 << 24) & (0xff << 24))
},
.
.
Can someone point me to an example of code that adds a SPI driver to an existing device driver?
Remember, I am a Linux newbie, so please be gentle..... <grin>
Thanks,
Steve
- 03-21-2009 #2Just Joined!
- Join Date
- Mar 2009
- Location
- Norway
- Posts
- 52
From within another SPI-driver, or just any driver? All SPI-drivers are drivers, and need to register as spi-driver...
Try:
git grep "spi_register_driver
in the kernel source dir an find other examples, IMHO, that's normally the best way to determine 'best practice'
No, sorry.
First off, at least you should return -ENOMEM as positive return is used to indicate the number of things. I.e. sscanf return the number of characters processed. Negative values indicate error.
Secondly, how sure are you that the status, not being 0, indicate out of memory? Why not just do a
?Code:if (status) return status;
grep the source. You probably know roughly what you're looking for
Look at drivers/spi/
and Documentation/spi
We're all newbies in some area or another
- 03-23-2009 #3Just Joined!
- Join Date
- Mar 2009
- Location
- Nashua, NH
- Posts
- 3
Hi,
Thanks for the suggestions. I will certainly look into those.
As for my driver, its a driver for a MAC/PHY chip written by someone else as a net_driver. This issue is that I need to access the internal MAC/PHY registers which are accessible only via SPI. So I need (I assume) to register a spi_driver from within a net_driver. I assume thats legal. Correct?
The folks who write the net_driver wrote the code to be interface independent as they make several variations of the chip. One is a SPI interface and other chips use other interfaces.
thanks,
Steve


Reply With Quote

