[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Ltib] SPI driver access in kernel mode
From: |
Mike R9FT |
Subject: |
Re: [Ltib] SPI driver access in kernel mode |
Date: |
Sat, 13 Nov 2010 11:32:10 +0500 |
Hi,
Have a look at this code in arch/arm/mach-lpc32xx/phy3250.c
You could modify it like this:
static int __init phy3250_spi_board_register(void)
{
#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
static struct spi_board_info info[] = {
{
.modalias = "spidev",
.max_speed_hz = 5000000,
.bus_num = 0,
.chip_select = 0,
.controller_data = &spi0_chip_info,
},
};
#elif defined(CONFIG_EEPROM_AT25) || defined(CONFIG_EEPROM_AT25_MODULE)
static struct spi_eeprom eeprom = {
.name = "at25256a",
.byte_len = 0x8000,
.page_size = 64,
.flags = EE_ADDR2,
};
static struct spi_board_info info[] = {
{
.modalias = "at25",
.max_speed_hz = 5000000,
.bus_num = 0,
.chip_select = 0,
.platform_data = &eeprom,
.controller_data = &spi0_chip_info,
},
};
#else
static struct spi_board_info info[] = {
{
.modalias = "my_spi_driver1",
.max_speed_hz = 1000000,
.bus_num = 0,
.chip_select = 0,
.controller_data = &spi0_chip_info,
},
{
.modalias = "my_spi_driver2",
.max_speed_hz = 1000000,
.bus_num = 1,
.chip_select = 0,
.controller_data = &spi1_chip_info,
},
};
#endif
return spi_register_board_info(info, ARRAY_SIZE(info));
}
arch_initcall(phy3250_spi_board_register);
Remove at25 and spidev drivers from kernel configuration menu and
recompile the kernel.
I know, it is not very well recompile the kernel when you only connect
some other spi device.
Here is quote from linux spi documentation: (see
http://www.kernel.org/doc/Documentation/spi/spi-summary)
<<
NON-STATIC CONFIGURATIONS
Developer boards often play by different rules than product boards, and one
example is the potential need to hotplug SPI devices and/or controllers.
For those cases you might need to use spi_busnum_to_master() to look
up the spi bus master, and will likely need spi_new_device() to provide the
board info based on the board that was hotplugged. Of course, you'd later
call at least spi_unregister_device() when that board is removed.
When Linux includes support for MMC/SD/SDIO/DataFlash cards through SPI, those
configurations will also be dynamic. Fortunately, such devices all support
basic device identification probes, so they should hotplug normally.
>>
I have tried this one, but it is not works for me. May be someone give
an example?
--
73! Mike R9FT ex. RA9FTM
2010/11/13 malay jajodia <address@hidden>:
> Hi All,
>
> I am using PHYTEC LPC3250 and i want to use SPI in kernel mode. I know that
> spi_read() and spi_write() will do the task but both these functions require
> spi_device as an argument. And i am not sure how to register an spi_device.
>
> Please help!!!
>
> -MJ