From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from ip2.televic.com ([81.82.194.222]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1T2LsF-0004sc-RE for barebox@lists.infradead.org; Fri, 17 Aug 2012 12:42:02 +0000 From: Vanalme Filip Date: Fri, 17 Aug 2012 14:41:53 +0200 Message-ID: <6EE7D1502C48E44E92DCADF9DD3E0DB901B0B366556B@SRV-VS06.TELEVIC.COM> Content-Language: en-US MIME-Version: 1.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============6203471829450673169==" Sender: barebox-bounces@lists.infradead.org Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: adding SPI port on i.MX27 board To: "barebox@lists.infradead.org" --===============6203471829450673169== Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_6EE7D1502C48E44E92DCADF9DD3E0DB901B0B366556BSRVVS06TELE_" --_000_6EE7D1502C48E44E92DCADF9DD3E0DB901B0B366556BSRVVS06TELE_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi, Currently, CSPI2 of the i.MX27 is used to communicate with its companion ch= ip (MC13783). This works fine. The SPI parts of the board file look like : static int imx27_interaxio_spi1_cs[] =3D {GPIO_PORTD + 21}; static struct spi_imx_master imx27_interaxio_spi_1_data =3D { .chipselect =3D imx27_interaxio_spi1_cs, .num_chipselect =3D ARRAY_SIZE(imx27_interaxio_spi1_cs), }; static struct spi_board_info imx27_interaxio_spi_board_info[] =3D { { .name =3D "mc13783", .max_speed_hz =3D 3000000, .bus_num =3D 0, .chip_select =3D 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[] =3D {GPIO_PORTD + 21}; static int imx27_interaxio_spi0_cs[] =3D {GPIO_PORTD + 28}; static struct spi_imx_master imx27_interaxio_spi_1_data =3D { .chipselect =3D imx27_interaxio_spi1_cs, .num_chipselect =3D ARRAY_SIZE(imx27_interaxio_spi1_cs), }; static struct spi_imx_master imx27_interaxio_spi_0_data =3D { .chipselect =3D imx27_interaxio_spi0_cs, .num_chipselect =3D ARRAY_SIZE(imx27_interaxio_spi0_cs), }; static struct spi_board_info imx27_interaxio_spi_board_info[] =3D { { .name =3D "mc13783", .max_speed_hz =3D 3000000, .bus_num =3D 0, .chip_select =3D 0, }, { .name =3D "LCD", .max_speed_hz =3D 2000000, .bus_num =3D 1, .chip_select =3D 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 scannin= g 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 t= he added bus, the bus_num is 1, so the compare will validate to false and t= he 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 --_000_6EE7D1502C48E44E92DCADF9DD3E0DB901B0B366556BSRVVS06TELE_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hi,

 

Currently, C= SPI2 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[] =3D {GPIO_PORTD + 21};=

static struct spi_imx_master imx27_interaxio_s= pi_1_data =3D {

    .= chipselect =3D imx27_interaxio_spi1_cs,

    .num_chipselect =3D ARRAY_SIZE(imx27_interaxio_spi1_= cs),

};

 

static struct spi_= board_info imx27_interaxio_spi_board_info[] =3D {

    {

&= nbsp;     .name =3D "mc13783",

      .max_speed_hz =3D 3= 000000,

    &nb= sp; .bus_num =3D 0,

  &nbs= p;   .chip_select =3D 0, /* offset in the chip select array */

    },

};

 = ;

[…]

 

static int imx27_in= teraxio_devices_init(void)

{

  […]

  /* PMIC support */

=   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 h= ad to change the board file like this :

 

static int imx27_i= nteraxio_spi1_cs[] =3D {GPIO_PORTD + 21};

static int imx27_interaxio_spi0_cs[] =3D {GPIO_PORTD + 28};=

static struct spi_imx_master imx27_= interaxio_spi_1_data =3D {

 &nb= sp;  .chipselect =3D imx27_interaxio_spi1_cs,

    .num_chipselect =3D ARRAY_SIZE(imx27_inte= raxio_spi1_cs),

};=

static struct spi_imx_master imx27_interaxi= o_spi_0_data =3D {

 &= nbsp;  .chipselect =3D imx27_interaxio_spi0_cs,

<= p class=3DMsoNormal>    .num_chipselect =3D ARRAY_SIZ= E(imx27_interaxio_spi0_cs),

static struct spi_board_inf= o imx27_interaxio_spi_board_info[] =3D {

    {

 &nbs= p;    .name =3D "mc13783",

      .max_speed_hz =3D 3000000,

      .bus_n= um =3D 0,

    &n= bsp; .chip_select =3D 0,

 &nbs= p;  },

 &nb= sp;  {

  &n= bsp;     .name =3D "LCD",

        .m= ax_speed_hz =3D 2000000,

&= nbsp;       .bus_num =3D 1,=

        = .chip_select =3D 0, 

    },

};<= /o:p>

 

[…]

 

static int imx27_interaxio_devices_init(void)=

{

  […]

  /* PMIC sup= port */

  spi_register_board_i= nfo(imx27_interaxio_spi_board_info, ARRAY_SIZE(imx27_interaxio_spi_board_in= fo));

  imx27_add_spi1(&imx= 27_interaxio_spi_1_data);

=   imx27_add_spi0(&imx27_interaxio_spi_0_data); <= /p>

[…]

 

&nbs= p;

However, I’m not sure I&#= 8217;m doing it right. E.g. for the bus_num element. As it is another ̵= 6;master’, I guess it should get another bus number. However, when di= gging 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 sc= anning for board info (scan_boardinfo in spi.c), bus_num of chip is compare= d 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

 

 

= --_000_6EE7D1502C48E44E92DCADF9DD3E0DB901B0B366556BSRVVS06TELE_-- --===============6203471829450673169== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox --===============6203471829450673169==--