All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andre Schwarz <andre.schwarz@matrix-vision.de>
To: Grant Likely <grant.likely@secretlab.ca>
Cc: LinuxPPC List <linuxppc-dev@ozlabs.org>
Subject: Re: How to define an I2C-to-SPI bridge device ?
Date: Tue, 29 Mar 2011 18:21:50 +0200	[thread overview]
Message-ID: <4D92071E.3060906@matrix-vision.de> (raw)
In-Reply-To: <4D8C603F.6060501@matrix-vision.de>

On 03/25/2011 10:28 AM, Andre Schwarz wrote:
> Grant, Anton,

got it.
providing modalis = "spidev" within spi_board_info works like a charme ...

Cheers,
André

>
>>>> we're about to get new MPC8377 based hardware with various 
>>>> peripherals.
>>>>> There are two I2C-to-SPI bridge devices (NXP SC18IS602) and I'm 
>>>>> not sure
>>>>> how to define a proper dts...
>>>>>
>>>>> Of course it's an easy thing creating 2 child nodes on the CPU's I2C
>>>>> device - but how can I represent the created SPI bus ?
>>>> Um.. the same as the other SPI buses? I.e.
>>>>
>>>> i2c-controller {  /* SOC I2C controller */
>>>>     spi-controller {  /* The I2C-to-SPI bridge */
>>>>         spi-device@0 {
>>>>         };
>>>>         spi-device@1 {
>>>>         };
>>>>     };
>>>> };
>>>>
>>> ok , thanks - looks straight forward.
>>> Is this any more than plain definition, i.e. will this trigger any I2C
>>> or SPI device registration/linking ?
>>>>> Is the (possibly) required driver (of_sc18is60x_spi ?) supposed to 
>>>>> be an
>>>>> I2C slave or an SPI host driver ?
>>>> It should be an I2C driver that registers an SPI master (i.e.
>>>> calls spi_alloc_master() and spi_register_master()).
>>> hmm - ok. Will have to do it manually then ...
>> Yes, but this is the case for non-of drivers too.  The i2c to spi 
>> device driver must always create (and trigger population of) the spi 
>> bus instance.
>>
>
> I've kicked that I2C-to-SPI stuff completely because it's been too slow.
> We've connected the SPI busses to the FPGA controlling almost 
> everything now.
>
> Unfortunately there are some questions left :
>
> Following Anton's suggestion I've had a look at /drivers/mfd (sm501.c) 
> and implemented a pci driver for the FPGA using
> subdevices for additional functionality it exports - besides others we 
> now have 2 SPI masters.
>
> For both SPI masters I have created and registered a platform_device.
> pdev->dev is then fed into spi_alloc_master() and the resulting master 
> goes into spi_register_master().
>
> master->bus_num is set to 0 and 1, i.e. no dynamic numbering.
> master->chipselect = 8;
>
> Since I can probe the SPI device using FPGA intrinsic information I 
> decided to register the client
> devices on runtime using a "struct spi_board_info" which is fed into 
> spi_new_device().
>
> The current design has 2 clients on SPI-0 and 5 clients on SPI-1.
>
> static struct spi_board_info mergerbox_spi_boardinfo[] = {
>         {       .bus_num = 0,
>                 .chip_select = 0,
>                 .max_speed_hz = 4<<20, },
>         {       .bus_num = 0,
>                 .chip_select = 1,
>                 .max_speed_hz = 4<<20, },
>         {       .bus_num = 1,
>                 .chip_select = 0,
>                 .max_speed_hz = 4<<20, },
> .....
>
>
> After loading my module I get :
>
> #> ls /sys/devices/platform/AlteraSPI.0/
> /sys/devices/platform/AlteraSPI.0/modalias
> /sys/devices/platform/AlteraSPI.0/spi0.0/
> /sys/devices/platform/AlteraSPI.0/spi0.1/
> /sys/devices/platform/AlteraSPI.0/spi_master/
> /sys/devices/platform/AlteraSPI.0/subsystem/
> /sys/devices/platform/AlteraSPI.0/uevent
>
> #> ls /sys/devices/platform/AlteraSPI.1/
> /sys/devices/platform/AlteraSPI.1/modalias
> /sys/devices/platform/AlteraSPI.1/spi1.0/
> /sys/devices/platform/AlteraSPI.1/spi1.1/
> /sys/devices/platform/AlteraSPI.1/spi1.2/
> /sys/devices/platform/AlteraSPI.1/spi1.3/
> /sys/devices/platform/AlteraSPI.1/spi1.4/
> /sys/devices/platform/AlteraSPI.1/spi_master/
> /sys/devices/platform/AlteraSPI.1/subsystem/
> /sys/devices/platform/AlteraSPI.1/uevent
>
> What I'm missing are the /dev/spi* entries.
>
> There's also a spi_mpc8xxx driver using the CPU's SPI controller.
> It is configured by dts (2 devices) and uses dynamic bus numbering:
>
> #> ls /sys/bus/spi/devices/
> spi0.0      spi1.0      spi1.2      spi1.4      spi32766.1
> spi0.1      spi1.1      spi1.3      spi32766.0
>
> This devices are processed by spidev and proper entries are created 
> ready for use :
>
> #> ls /dev/spi*
> /dev/spidev32766.0  /dev/spidev32766.1
>
>
> Am I missing somehting obvious ?
>
> Since there's no driver registration we don't have a probe function - 
> is this a problem regarding device binding ?
>
> Do I need to use the .modalias in "struct spi_board_info" ?
>
>
> Any help is welcome.
>
> Regards,
> André


MATRIX VISION GmbH, Talstrasse 16, DE-71570 Oppenweiler
Registergericht: Amtsgericht Stuttgart, HRB 271090
Geschaeftsfuehrer: Gerhard Thullner, Werner Armingeon, Uwe Furtner

  reply	other threads:[~2011-03-29 16:27 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-03  8:36 How to define an I2C-to-SPI bridge device ? André Schwarz
2010-09-03 12:08 ` Anton Vorontsov
2010-09-03 12:08   ` Anton Vorontsov
2010-09-06 11:40   ` Andre Schwarz
2010-09-06 11:40     ` Andre Schwarz
2010-09-06 14:37     ` André Schwarz
2010-09-06 14:37       ` André Schwarz
2010-09-09 18:23     ` Grant Likely
2010-09-09 18:23       ` Grant Likely
2010-09-10  8:11       ` André Schwarz
2010-09-10 17:37         ` Grant Likely
2010-09-10 17:37           ` Grant Likely
2010-09-10 18:14           ` André Schwarz
2010-09-10 18:14             ` André Schwarz
2010-09-10 18:27             ` Anton Vorontsov
2010-09-10 18:27               ` Anton Vorontsov
2010-09-10 18:28             ` Grant Likely
2010-09-10 18:28               ` Grant Likely
2010-09-12 15:10               ` André Schwarz
2010-09-12 15:10                 ` André Schwarz
2010-09-13  4:39                 ` Grant Likely
2010-09-13  4:39                   ` Grant Likely
2011-03-25  9:28       ` Andre Schwarz
2011-03-29 16:21         ` Andre Schwarz [this message]
2011-03-31  3:43           ` Grant Likely
2010-09-09 17:06 ` Grant Likely
2010-09-09 17:06   ` Grant Likely

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=4D92071E.3060906@matrix-vision.de \
    --to=andre.schwarz@matrix-vision.de \
    --cc=grant.likely@secretlab.ca \
    --cc=linuxppc-dev@ozlabs.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.