adding SPI port on i.MX27 board

Vanalme Filip F.Vanalme at TELEVIC.com
Fri Aug 17 08:41:53 EDT 2012


Hi,

Currently, CSPI2 of the i.MX27 is used to communicate with its companion chip (MC13783). This works fine. The SPI parts of the board file look like :

static int imx27_interaxio_spi1_cs[] = {GPIO_PORTD + 21};
static struct spi_imx_master imx27_interaxio_spi_1_data = {
    .chipselect = imx27_interaxio_spi1_cs,
    .num_chipselect = ARRAY_SIZE(imx27_interaxio_spi1_cs),
};

static struct spi_board_info imx27_interaxio_spi_board_info[] = {
    {
      .name = "mc13783",
      .max_speed_hz = 3000000,
      .bus_num = 0,
      .chip_select = 0, /* offset in the chip select array */
    },
};

[...]

static int imx27_interaxio_devices_init(void)
{
  [...]
  /* PMIC support */
  spi_register_board_info(imx27_interaxio_spi_board_info, ARRAY_SIZE(imx27_interaxio_spi_board_info));
  imx27_add_spi1(&imx27_interaxio_spi_1_data);
[...]


Now, I would like to add another SPI port of the i.MX27, CSPI1, to control an LCD. To do that, I taught I had to change the board file like this :

static int imx27_interaxio_spi1_cs[] = {GPIO_PORTD + 21};
static int imx27_interaxio_spi0_cs[] = {GPIO_PORTD + 28};
static struct spi_imx_master imx27_interaxio_spi_1_data = {
    .chipselect = imx27_interaxio_spi1_cs,
    .num_chipselect = ARRAY_SIZE(imx27_interaxio_spi1_cs),
};
static struct spi_imx_master imx27_interaxio_spi_0_data = {
    .chipselect = imx27_interaxio_spi0_cs,
    .num_chipselect = ARRAY_SIZE(imx27_interaxio_spi0_cs),
};
static struct spi_board_info imx27_interaxio_spi_board_info[] = {
    {
      .name = "mc13783",
      .max_speed_hz = 3000000,
      .bus_num = 0,
      .chip_select = 0,
    },
    {
        .name = "LCD",
        .max_speed_hz = 2000000,
        .bus_num = 1,
        .chip_select = 0,
    },
};

[...]

static int imx27_interaxio_devices_init(void)
{
  [...]
  /* PMIC support */
  spi_register_board_info(imx27_interaxio_spi_board_info, ARRAY_SIZE(imx27_interaxio_spi_board_info));
  imx27_add_spi1(&imx27_interaxio_spi_1_data);
  imx27_add_spi0(&imx27_interaxio_spi_0_data);
[...]


However, I'm not sure I'm doing it right. E.g. for the bus_num element. As it is another 'master', I guess it should get another bus number. However, when digging a little in the code, in imx_spi_probe (imx_spi.c), bus_num of 'master' is never initialized, so always 0. A little further, when scanning for board info (scan_boardinfo in spi.c), bus_num of chip is compared to bus_num of master, which is always 0. For the existing implementation this was not a problem as the bus_num in the board info struct was also 0. For the added bus, the bus_num is 1, so the compare will validate to false and the device will not be created...
This is how I'm think it's working. Am I correct ?
Am I doing something wrong ? Should I also use bus_num 0 for my additional SPI instead of 1 ?

Thanks in advance for helping me !

Filip Vanalme


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20120817/ed59cd90/attachment.html>


More information about the barebox mailing list