imx28 spi GPIO bit bang

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

imx28 spi GPIO bit bang

1,738 Views
shashikanthirem
Contributor III

Does spidev works only on spi-mxs driver, because if i enable spidev over spi-gpio the kernel doesn't populate /dev/spidevx.x , with disabled kernel config spi-mxs driver,

does anyone faced similar issue ?

Labels (1)
0 Kudos
6 Replies

1,545 Views
shashikanthirem
Contributor III

Working now

0 Kudos

1,545 Views
weidong_sun
NXP TechSupport
NXP TechSupport

OK, got it.

good job!

Have a nice day!

B.R,

Weidong

0 Kudos

1,545 Views
shashikanthirem
Contributor III

in this method multiple spimxs_probe does not work, which ever is the max configured from device.c it consider. any solution on this?

currently its not blocking, as of now,

for example:

spi0.1

spi1.2

spi2.1

in this scenario it always calls spi2.1, not the rest of spi ioctl is call fail

0 Kudos

1,545 Views
weidong_sun
NXP TechSupport
NXP TechSupport

Hi shashikant,

   It seems that there is something wrong with steps on simulation of GPIO to SPI, i.MX28's BSP is old version of linux, whose final version is 2.6.35. so steps below if for you reference.

1. positions of source code

linux/drivers/spi/spi_gpio.c
linux/include/linux/spi_gpio.h
linux/include/linux/spi_bitbang.h

2. data structure

struct spi_gpio_platform_data {
unsigned sck;
unsigned mosi;
unsigned miso;
u16 num_chipselect;
};

For the first three members, we need to use GPIO on the CPU to assign values. And the fourth member is the number of chip selections, For example, num_chipselect = 4, means that this SPI BUS allows 4 Slave Devices.

3. Customers can follow it to use it

(1)In mx28evk.c, add code at the beginning

**** Define GPIO, interface with linux gpio, the following pins are assumed, the customer can modify it according to the situation:

#include<linux/spi_gpio.h>
#include<linux/spi_bitbang.h>
#define GPIO_SPI_SCLK MXS_PIN_TO_GPIO(PINID_PWM2)
#define GPIO_SPI_MOSI MXS_PIN_TO_GPIO(PINID_PWM3)
#define GPIO_SPI_MISO MXS_PIN_TO_GPIO(PINID_PWM4)
#define GPIO_SPI_CS0 MXS_PIN_TO_GPIO(PINID_SPDIF)

static struct spi_gpio_platform_data gpio_spi_data = {
. sck = GPIO_SPI_SCLK,
. mosi = GPIO_SPI_MOSI,
. miso = GPIO_SPI_MISO,
. num_chipselect = 1,
}

*** Define GPIO SPI device

struct platform_device gpio_spi_device = {
.name = " spi_gpio",
.id = 5,
.dev = {
. platform_data = & gpio_spi_data,
},
};

*** In the existing spi_board_info definition, add the device connected by the customer to the GPIO SPI:

static struct spi_board_info spi_board_info[] __initdata = {
#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
{
/* the modalias must be the same as spi device driver name */
.modalias = "m25p80", /* Name of spi_driver for this device */
.max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
.bus_num = 1, /* Framework bus number */
.chip_select = 0, /* Framework chip select. */
.platform_data = &mx28_spi_flash_data,
},
endif

‌/ * The device connected to GPIO_SPI Bus --- customer modify it by himself * /

{
.modalias = "customer device name", /* Name of spi_driver for this device */
.max_speed_hz = 50000, /* max spi clock (SCK) speed in HZ */
.bus_num = 5, /* the same as spi controller ID */
.controller_data = (void *)GPIO_SPI_CS0, /* Used as chip select. */
.platform_data = &gpio_spi_device_data, /* customer define*/
} ,
};

*** Register GPIO SPI device, add in static void spi_device_init (void) function:

static void spi_device_init(void)
{
platform_device_register(gpio_spi_device);
spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
}

4. When compiling the kernel, select the spi gpio module

From linux / driver / spi / Kconfig & Makefile, you can know its position in the kernel configuration menu.

Hope above information is helpful for you!

Have a nice day!

B.R,

Weidong

0 Kudos

1,545 Views
shashikanthirem
Contributor III

Hi Weidong,

Thanks for your input, 

SPI2_SS1 --  SPI2 with Slave select 1

 

i did this experiment before posting question, i followed your steps and i can able to add and SPI-GPIO probe was success, 

case1:

1. Disabled spi-mxs.c

2. enable the platform data for spi-gpio, where the probe was succeeded

3.No file created /dev/spidev2.1

case 2:

1. Enable spi-mxs.c , where the probe was succeeded

2. enable the platform data for spi-gpio, where the probe was succeeded

3.created /dev/spidev2.1

4. when i call ioctl spi read/ write on  /dev/spidev2.1, its always calling spi-mxs.c rather than spi-gpio.c

but dont know  why drivers/spi/spidev.c ioctl R/W calls to spi-mxs.c, where i didn't register on it

Not sure what the step i am missing for case1 to get it work, may be i will reconfirm once again

Note :

1. I dont have any modalias

.modalias = "spidev", \  --- not sure i am right

i just need flow 

create /dev/spidev2.1

spidev.c ---  ioctl call present 

spi_gpio.c , where it takes care of send and receive data to peripheral from here

0 Kudos

1,545 Views
shashikanthirem
Contributor III

Found platform data is not matching with master platform which is at driver/spi/spi.c not sure 

0 Kudos