2010-05-12 15:17:01 Little Question abou register a SPI Kernel driver
Raphael Lang (GERMANY)
Message: 89338
Hey People,
I just wana write a simple driver to acces a microkontroller over SPI Framework...
I just follow the tutorial:
linux-2.6.x/arch/blackfin/mach-bf537/boards/stamp.c.
I edit the file like that:
#if defined(CONFIG_PIC_SPI) || defined(CONFIG_PIC_SPI_SPIDEV_MODULE)
static struct bfin5xx_spi_chip pic_spi_chip_info = {
.enable_dma = 0,
.bits_per_word = 8,
};
#endif
and
#if defined(CONFIG_PIC_SPI) || defined(CONFIG_PIC_SPI_SPIDEV_MODULE)
{
.modalias = "pic_spi",
.max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
.bus_num = 0,
.chip_select = 2,
.controller_data = &pic_spi_chip_info,
},
#endif
Now I should register the Kernel driver.
static struct spi_driver pic_spi_driver = {
.driver = {
.name = "pic_spi",
.bus = &spi_bus_type,
.owner = THIS_MODULE,
},
.probe = pic_spi_probe,
.remove = __devexit_p(pic4_spi_remove),
};
.....
But where I need to put the code ? which file I need to edit or create ?
thanks
Raph
TranslateQuoteReplyEditDelete
2010-05-12 18:38:03 Re: Little Question abou register a SPI Kernel driver
Mike Frysinger (UNITED STATES)
Message: 89342
can you just use the normal spidev interface instead ? why must your driver be in kernel space ?
QuoteReplyEditDelete
2010-05-13 13:19:36 Re: Little Question abou register a SPI Kernel driver
Raphael Lang (GERMANY)
Message: 89381
well, I tought I can use the interrupts of the Kernel Driver, but lets make thinks easy...
so I need to config the boardfile like that :
#if defined(CONFIG_PIC_SPI) || defined(CONFIG_PIC_SPI_SPIDEV_MODULE)
static struct bfin5xx_spi_chip pic_spi_chip_info = {
.enable_dma = 0,
.bits_per_word = 8,
};
#endif
and
#if defined(CONFIG_PIC_SPI) || defined(CONFIG_PIC_SPI_SPIDEV_MODULE)
{
.modalias = "spidev",
.max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
.bus_num = 0,
.chip_select = 2,
.controller_data = &pic_spi_chip_info,
},
#endif
and after booting it will displayed spidev0.2
Did i need modprobe spidev0.2 ore something like that ?
TranslateQuoteReplyEditDelete
2010-05-14 04:23:41 Re: Little Question abou register a SPI Kerneldriver
Michael Hennerich (GERMANY)
Message: 89402 Take a look here:
docs.blackfin.uclinux.org/doku.php?id=spi&s[]=spidev
Spidev (CONFIG_SPI_SPIDEV) is a user space driver - you need to build the driver into your kernel or load the module afterwards.
The module will be called spidev.ko
You can find some usage example here:
uclinux-dist-trunk/user/blkfin-apps/fpga/fpga_loader
-Michael
QuoteReplyEditDelete
2010-05-14 15:36:07 Re: Little Question abou register a SPI Kerneldriver
Raphael Lang (GERMANY)
Message: 89419
jep I saw the documentation about the SPI , my Questions is:
Did I need to register my usermoder SPI Driver like that for my additional device:
#if defined(CONFIG_PIC_SPI) || defined(CONFIG_PIC_SPI_SPIDEV_MODULE)
...
};
#endif
and
#if defined(CONFIG_PIC_SPI) || defined(CONFIG_PIC_SPI_SPIDEV_MODULE)
{
.modalias = "spidev",
.....
},
#endif
because the documentations told me I should find the new device in /spidev0.2.
but there is nothing in /dev that sounds like my spi device ?
I could also not load anything with modprobe spidev.ko ?
Gruß von Stuttgart nach München
raph
TranslateQuoteReplyEditDelete
2010-05-15 11:37:41 Re: Little Question abou register a SPI Kerneldriver
Raphael Lang (GERMANY)
Message: 89434
OK, now I understand, its easy like that:
// For SPI Device 1
#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
{
.modalias = "spidev",
.max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
.bus_num = 0,
.chip_select =2,
.controller_data = &spidev_chip_info,
},
//For SPI Device 2
#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
{
.modalias = "spidev",
.max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
.bus_num = 0,
.chip_select = 3,
.controller_data = &spidev_chip_info,
},
Now I can see all the devices spidev0.2 and spidev0.3 in /dev.
but now I have trouble with my AD 1836 (SPI_SSEL_4 ) after Booting :
mmc_spi spi0.1: ASSUMING 3.2-3.4 V slot power
mmc_spi spi0.1: SD/MMC host mmc0, no DMA, no WP, no poweroff
mmc_spi spi0.1: requested mode not fully supported
mmc_spi spi0.1: can't change chip-select polarity
Advanced Linux Sound Architecture Driver Version 1.0.18rc3.
dma_alloc_init: dma_page @ 0x0329a000 - 256 pages at 0x03f00000
Hardware Trace:
0 Target : <0x00004b44> { _dump_stack + 0x0 }
....
peripheral_request: Peripheral 59 function 0 is already reserved by spidev !
bf53x_sport: Requesting Peripherals failed
AD1836: Failed to find device on sport
ALSA device list:
No soundcards found.
cheers
Raphael
TranslateQuoteReplyEditDelete
2010-05-16 14:46:30 Re: Little Question abou register a SPI Kerneldriver
Mike Frysinger (UNITED STATES)
Message: 89449
so select a different pin that isnt being used, or disable devices you arent using
QuoteReplyEditDelete
2010-05-16 14:47:19 Re: Little Question abou register a SPI Kernel driver
Mike Frysinger (UNITED STATES)
Message: 89450
interrupts can be leveraged via the UIO interface, but typically SPI devices dont have dedicated interrupt lines. what interrupt exactly are you talking about ?
QuoteReplyEditDelete
2010-05-19 12:55:54 Re: Little Question abou register a SPI Kernel driver
Raphael Lang (GERMANY)
Message: 89552
jep, I have reed in a Linux Boock, that maybee it is better to use a kernel driver...
well, do have an Idea why thy soundcard makes a problem when I am booting ?
thanks
Raph
TranslateQuoteReplyEditDelete
2010-05-19 12:58:12 Re: Little Question abou register a SPI Kernel driver
Raphael Lang (GERMANY)
Message: 89553
jep, I have reed in a Linux Boock, that maybee it is better to use a kernel driver...
well, do have an Idea why thy soundcard makes a problem when I am booting ?
thanks
Raph
---
SPI CHIP SELECT 4 is only used by the soundcart
TranslateQuoteReplyEditDelete
2010-05-19 15:21:49 Re: Little Question abou register a SPI Kernel driver
Mike Frysinger (UNITED STATES)
Message: 89556
if that were true, you wouldnt have gotten the error. double check your board resources.
QuoteReplyEditDelete
2010-05-27 06:01:07 Re: Little Question abou register a SPI Kernel driver
Raphael Lang (GERMANY)
Message: 89911
well, I pluged my addtional devices from the spi bus, so only the AD 1836 and the mmc card are connected to the spi
bus... so it should boot normally ....but the message still apear...it seems when I only add the devices in the stamp.c file
there will be a problem ?
the Soundcart ad 1836 is on SPI_CS 4, MMC on SPI_CS_1, and 5 x(MAX7301 on SPI_CS_2, MAX7301 on SPI_CS_3 MAX 7301 on SPI_CS_5, MAX 7301 SPI_CS 6 and a MAX7301 on SPI_CS_7)
I added my stamp.c file
thanks
Raph
stamp.c
TranslateQuoteReplyEditDelete
2010-05-27 17:21:32 Re: Little Question abou register a SPI Kernel driver
Mike Frysinger (UNITED STATES)
Message: 89927
which devices are physically connected is irrelevant to the resource management in the kernel
you've never said what hardware platform you're actually using nor what version of software. in general, you need to fully describe these things when asking questions.