From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: Vanalme Filip <F.Vanalme@TELEVIC.com>
Cc: "barebox@lists.infradead.org" <barebox@lists.infradead.org>
Subject: Re: adding SPI port on i.MX27 board
Date: Sat, 18 Aug 2012 11:08:05 +0200 [thread overview]
Message-ID: <20120818090805.GU6271@game.jcrosoft.org> (raw)
In-Reply-To: <6EE7D1502C48E44E92DCADF9DD3E0DB901B0B366556B@SRV-VS06.TELEVIC.COM>
On 14:41 Fri 17 Aug , Vanalme Filip wrote:
> 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 ?
I get the same issue on at91 recently I send a patch to detect this issue
here you have 2 choice use the dynamic bus num allocation or manual but all
the bus must have a different bus_num
Best Regards,
J.
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2012-08-18 9:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-17 12:41 Vanalme Filip
2012-08-18 9:08 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120818090805.GU6271@game.jcrosoft.org \
--to=plagnioj@jcrosoft.com \
--cc=F.Vanalme@TELEVIC.com \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox