According to the MX53 doc, I found that the configuration of the CSPI on MX53 as below
static struct mxc_spi_master mxcspi3_data = {
.maxchipselect = 4,
.spi_version = 23,
.chipselect_active = NULL,
.chipselect_inactive = NULL,
};
struct platform_device mxcspi3_device = {
.name = "mxc_spi",
.id = 2,
.num_resources = ARRAY_SIZE(mxcspi3_resources),
.resource = mxcspi3_resources,
};
mxc_register_device(&mxcspi3_device, &mxcspi3_data);
but I can not get the clk pulse on the PIN cspi_clk when I use the function spi_sync() to send data !
However, I can configure the eCSPI1 successfully with mxcspi1_device, I can get the clk pulse on the PIN ecspi_clk
so, How to configure the CSPI and make it work?
hi jacky,
i´m very new in linux drivers, can you explain me what you mean with test driver? you don´t use the mx_spi driver?
i configured the spi like you, but i dont know how to access it. i usually use devices with files in /dev or /sys
sorry, beacause my poor english, you have't get my point
1. you must confirm that the device connect to which spi bus. ecspi1, ecspi2 or cspi
then, you set the correct bus num to the struct as below:
static struct spi_board_info mxc_dataflash_device[] __initdata = {
{
.modalias = "mxc_dataflash",
.max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
.bus_num = 1, // set the correct bus num here
.chip_select = 1, //set the correct chip select here
.platform_data = &mxc_spi_flash_data[0],
},
};
2. register the spi bus
mxc_register_device(&mxcspi1_device, &mxcspi1_data); //if the device connect to the ecspi1
3.register the spi slave device
spi_register_board_info(mxc_dataflash_device,
ARRAY_SIZE(mxc_dataflash_device));
my last reply means you exchange the sequence.
4. if you device can't work , you must confirm whether the spi pin(miso, mosi, clk) have signal or not.
the easiest way is write a test driver for the spi controller, then test the spi pin by the Oscilloscope. if the spi pin
doesn't have signal, you must check whether you have config the spi pin correctlly!!
Hi Jacky,
thank for the reply!
I'm still on this problem. I haven't too much experience on this stuff... Do you thing I have to switch mxc_register_device and spi_register_board_info?! I'll try this morning.
What do you mean exactly with "test spi bus"?
sorry for reply so late!
if your sample code as above have no error , I think the problem is the function call sequence.
you should call the mxc_register_device() func first, then call the mxc_register_device() func.
on the other hand, you can write a test spi driver to test the spi bus work or not.
meanwhile, you can detect the signal on the spi pin by the Oscilloscope.
Hi,
I'm going crazy with spi on IMX53.
I followed your instruction but the spi doesn't appear in the device list!!!!!
Why? Sob :(
What's the right point to register the device?
This is my configuration:
- mx53_evk.c
static struct mxc_spi_master mxcspi1_data = {
.maxchipselect = 4,
.spi_version = 23,
.chipselect_active = mx53_evk_gpio_spi_chipselect_active,
.chipselect_inactive = mx53_evk_gpio_spi_chipselect_inactive,
};
static struct flash_platform_data mxc_spi_flash_data[] = {
{
.name = "mxc_dataflash",
.parts = mxc_dataflash_partitions,
.nr_parts = ARRAY_SIZE(mxc_dataflash_partitions),
.type = "at45db321d",}
};
static struct spi_board_info mxc_dataflash_device[] __initdata = {
{
.modalias = "mxc_dataflash",
.max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
.bus_num = 1,
.chip_select = 1,
.platform_data = &mxc_spi_flash_data[0],
},
};
spi_register_board_info(mxc_dataflash_device,
ARRAY_SIZE(mxc_dataflash_device));
mxc_register_device(&mxcspi1_device, &mxcspi1_data);
- devices.c
static struct resource mxcspi1_resources[] = {
{
.start = CSPI1_BASE_ADDR,
.end = CSPI1_BASE_ADDR + SZ_4K - 1,
.flags = IORESOURCE_MEM,
},
{
.start = MXC_INT_CSPI1,
.end = MXC_INT_CSPI1,
.flags = IORESOURCE_IRQ,
},
};
struct platform_device mxcspi1_device = {
.name = "mxc_spi",
.id = 0,
.num_resources = ARRAY_SIZE(mxcspi1_resources),
.resource = mxcspi1_resources,
};
Finally, I get the resolution by myself.
I found that mx50 configure the spi as below which you can find out in the source file mx50_rdp.c
static struct mxc_spi_master mxcspi3_data = {
.maxchipselect = 4,
.spi_version = 7,
.chipselect_active = mx50_rdp_gpio_spi_chipselect_active,
.chipselect_inactive = mx50_rdp_gpio_spi_chipselect_inactive,
};
the key is you must set the .spi_version to 7 not 23, 23 is for the ecspi
Now, the CSPI works!