2008-12-08 07:12:12 SPI and BF-561
Filip Vanalme (BELGIUM)
Message: 66501
this item might already been discussed earlier. I looked into some forum discussions, but never found exactly what I'm looking for...
I'm developing on a BF-561 board with Kernel version 2.6.16.11 (2006R1).
I think I followed the instructions from the SPI doc (http://docs.blackfin.uclinux.org/doku.php?id=spi) . However, I did not succeed in making my SPI device driver working.
(...I have to admit : I'm not an experienced Linux device driver developer...).
I adjusted the Kconfig and Makefile of /drivers/spi to include my file :
* Kconfig
....
config SPI_TLV
tristate "TLV SPI support"
depends on SPI_MASTER && EXPERIMENTAL
help
Company SPI driver.
....
* Makefile
obj-$(CONFIG_SPI_TLV) += spi_tlv.o
In menuconfig :
[*] SPI support
[*] SPI Master Support
--- SPI Master Controller Drivers
[ ] Bitbanging SPI master
[*] TLV SPI support
--- SPI Protocol Masters
[*] SPI controller driver for ADI Blackfin5xx
I think this is OK because my souce file gets compiled. And spi_bfin5xx was build too.
I also adjusted /arch/blackfin/mach-bf561/boards/ezkit.c :
...
static struct bfin5xx_spi_chip spi_tlv_chip_info = {
.ctl_reg = 0x1000,
.enable_dma = 0,
.bits_per_word = 16,
};
/* Notice: for blackfin, the speed_hz is the value of register
SPI_BAUD, not the real baudrate */
static struct spi_board_info bfin_spi_board_info[] __initdata = {
...
#if defined(CONFIG_SPI_TLV) || defined(CONFIG_SPI_TLV_MODULE)
{
.modalias = "tlv-spi",
.max_speed_hz = 16,
.bus_num = 0,
.chip_select = 1,
.platform_data = NULL,
.controller_data = &spi_tlv_chip_info,
},
...
#endif
};
/* SPI controller data */
static struct bfin5xx_spi_master spi_bfin_master_info = {
.num_chipselect = 8,
.enable_dma = 1, /* master has the ability to do dma transfer */
};
static struct platform_device spi_bfin_master_device = {
.name = "bfin-spi-master",
.id = 1, /* Bus number */
.dev = {
.platform_data = &spi_bfin_master_info, /* Passed to driver */
},
};
#endif /* spi master and devices */
static struct platform_device *ezkit_devices[] __initdata = {
&uart_16c554_device,
&smsc911x_device,
&bfin_gpios_device,
#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
&spi_bfin_master_device,
#endif
};
static int __init ezkit_init(void)
{
int status;
printk("%s(): registering device resources\n", __FUNCTION__);
printk("Adding devices\n");
status = platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
if (status < 0)
{
printk("Error while adding devices : %d", status);
}
#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
printk("Registering board info\n");
status = spi_register_board_info(bfin_spi_board_info,
ARRAY_SIZE(bfin_spi_board_info));
if (status < 0)
{
printk("Error while registering board infor : %d", status);
}
#endif
return status;
}
arch_initcall(ezkit_init);
And this is part of my source file :
static int __devinit bfin_spi_tlv_probe(struct spi_device *spi)
{
int ret = 0;
printk("Probing for tlv spi device..");
return ret;
}
static struct spi_driver tlv_spi_driver = {
.driver = {
.name = "tlv-spi",
.bus = &spi_bus_type,
.owner = THIS_MODULE,
},
.probe = bfin_spi_tlv_probe,
.remove = __devexit_p(bfin_spi_tlv_remove),
};
static int __init bfin_spi_tlv_init(void)
{
int result;
printk("Initiating TLV SPI ...\n");
result = spi_register_driver(&tlv_spi_driver);
if (result < 0)
{
printk(KERN_WARNING "SPI: can't register driver (%d)\n", result);
return result;
}
}
static void __exit bfin_spi_tlv_exit(void)
{
spi_unregister_driver(&tlv_spi_driver);
}
module_init(bfin_spi_tlv_init);
module_exit(bfin_spi_tlv_exit);
static int __devexit bfin_spi_tlv_remove(struct spi_device *spi)
{
printk(KERN_ALERT "Goodbye SPI\n");
return 0;
}
When the kernel starts, I get messages indicating that the init and probe function of spi_bfinxxx.c were called succesfully. I also get an indication that my own init function was called ("Initiating TLV SPI..."). But never an indication of entering my probe function. (No indication of problems when registering e.g. the driver, so I assume everthing went OK)
When I do a cat /proc/devices at the root prompt, I don't see any SPI related device. As long as I don't have that device in the list, I don't have to try an open() command, correct ?
I'm sure I'm still missing something. Anybody can help ?
Thanks!
TranslateQuoteReplyEditDelete
2008-12-08 07:57:50 Re: SPI and BF-561
Robin Getz (UNITED STATES)
Message: 66502
Filip:
Please upgrade to a more recent release (2008R1.5) - both the documentation will match, and the stuff will work.
-Robin
QuoteReplyEditDelete
2008-12-08 08:34:20 Re: SPI and BF-561
Filip Vanalme (BELGIUM)
Message: 66505
Robin,
Can I use spidev instead ? Or will I end up with the same 2006R1 problems ?
TranslateQuoteReplyEditDelete
2008-12-08 08:44:56 Re: SPI and BF-561
Filip Vanalme (BELGIUM)
Message: 66506
At this time, it's impossible to upgrade to 2008R1.5. We have a number of drivers for specific devices that we can't upgrade in short term. Products will be shipped in short term and we won't take the risk of changing to a new kernel release (moreover, we don't have the time to do that). In the long term, we certainly have to go to the most recent release.
So, for now, I have to continue on 2006R1. Any chance to get SPI working with that release ? Do I have to make modification to my sources to make this work ? Can I find somewhere information, for release 2006R1, on how to proceed to get the SPI work ?
TranslateQuoteReplyEditDelete
2008-12-08 08:45:52 Re: SPI and BF-561
Robin Getz (UNITED STATES)
Message: 66507
Filip:
2006R1 is so old I'm not sure what issues you will run into. We only support trunk and last release.
-Robin
QuoteReplyEditDelete
2008-12-08 12:22:19 Re: SPI and BF-561
Mike Frysinger (UNITED STATES)
Message: 66514
spidev did not exist in 2006R1 ... only 2008R1+
QuoteReplyEditDelete
2008-12-08 12:23:52 Re: SPI and BF-561
Mike Frysinger (UNITED STATES)
Message: 66515
try setting your bus_number to 0 in the spi_board_info array
QuoteReplyEditDelete
2008-12-09 02:24:56 Re: SPI and BF-561
Filip Vanalme (BELGIUM)
Message: 66540
Mike,
The bus number is already 0 in spi_board_info (see code parts in my original message). Or do I miss something ?
TranslateQuoteReplyEditDelete
2008-12-09 02:38:15 Re: SPI and BF-561
Filip Vanalme (BELGIUM)
Message: 66541
Robin,
If I understand well, the method I used was correct. It should work that way. Correct ?
Just wondering : would it be possible to backport the SPI related parts from 2008 to 2006 version ? It will certainly take effort, but maybe worthwile trying... Or would this be almost impossible ?
(Files that I have to adjust certainly : spi.c, spi_bfin5xx.c and related header files. Others ?)
TranslateQuoteReplyEditDelete
2008-12-09 07:55:30 Re: SPI and BF-561
Robin Getz (UNITED STATES)
Message: 66562
Filip:
The kernel in 2006R1 (2.6.16.11) is alot different than 2008R1 (2.6.22.19) We don't keep track of what is different in the common SPI functions which our driver tracked - and now works with. I don't know if it is practical just to backport a small driver.
-Robin
QuoteReplyEditDelete
2008-12-09 08:02:01 Re: SPI and BF-561
Mike Frysinger (UNITED STATES)
Message: 66563
i was referring to the definition of the SPI bus master ... you call it "bfin-spi-master" and give it an id of 1 ? you might want to verify that is correct ...
btw, you sure that max_speed_hz is correct ? it really only runs as 16 HZ ? that's pretty sloooooow ...