mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* adding SPI port on i.MX27 board
@ 2012-08-17 12:41 Vanalme Filip
  2012-08-18  9:08 ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 2+ messages in thread
From: Vanalme Filip @ 2012-08-17 12:41 UTC (permalink / raw)
  To: barebox


[-- Attachment #1.1: Type: text/plain, Size: 2935 bytes --]

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



[-- Attachment #1.2: Type: text/html, Size: 14445 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-08-18  9:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-17 12:41 adding SPI port on i.MX27 board Vanalme Filip
2012-08-18  9:08 ` Jean-Christophe PLAGNIOL-VILLARD

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox