* Generic MMC-over-SPI binding?
@ 2008-01-08 14:22 Simon Richter
2008-01-08 16:11 ` Robert Schwebel
2008-01-08 17:27 ` Arnd Bergmann
0 siblings, 2 replies; 6+ messages in thread
From: Simon Richter @ 2008-01-08 14:22 UTC (permalink / raw)
To: linuxppc-dev, linuxppc-embedded
Hi,
in an embedded system similar to the lite5200 board, there is an MMC
card socket connected to one of the PSCs. Ideally, I'd like to express
this fact via the device tree and have the kernel bind the mmc-spi
driver to the SPI interface, but I cannot find any place where to insert
this code that I feel comfortable with.
- It is not a board-specific thing, because any board can just use any
SPI bus for MMC.
- The mmc-spi driver appears to be platform independent, so I'm not
sure OF bindings should be added to it.
- The generic device tree scanning does not contain any special cases
yet, so I don't want to add one.
My current thought is to create a new driver that just handles MMC on
PSCs in SPI mode by gluing all the relevant drivers together, but that
doesn't seem optimal to me either.
Any ideas?
Simon
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: Generic MMC-over-SPI binding? 2008-01-08 14:22 Generic MMC-over-SPI binding? Simon Richter @ 2008-01-08 16:11 ` Robert Schwebel 2008-01-08 16:29 ` Simon Richter 2008-01-08 17:27 ` Arnd Bergmann 1 sibling, 1 reply; 6+ messages in thread From: Robert Schwebel @ 2008-01-08 16:11 UTC (permalink / raw) To: Simon Richter; +Cc: linuxppc-dev, linuxppc-embedded On Tue, Jan 08, 2008 at 03:22:00PM +0100, Simon Richter wrote: > in an embedded system similar to the lite5200 board, there is an MMC > card socket connected to one of the PSCs. Ideally, I'd like to express > this fact via the device tree and have the kernel bind the mmc-spi > driver to the SPI interface, but I cannot find any place where to insert > this code that I feel comfortable with. > > - It is not a board-specific thing, because any board can just use any > SPI bus for MMC. > > - The mmc-spi driver appears to be platform independent, so I'm not > sure OF bindings should be added to it. > > - The generic device tree scanning does not contain any special cases > yet, so I don't want to add one. > > My current thought is to create a new driver that just handles MMC on > PSCs in SPI mode by gluing all the relevant drivers together, but that > doesn't seem optimal to me either. You know this driver? http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=drivers/mmc/host/mmc_spi.c;h=365024b83d3da9df9b6e4f7a9d4cf6d216ba523d;hb=HEAD Or is your question how to express this in the device tree? Robert -- Dipl.-Ing. Robert Schwebel | http://www.pengutronix.de Pengutronix - Linux Solutions for Science and Industry Handelsregister: Amtsgericht Hildesheim, HRA 2686 Hannoversche Str. 2, 31134 Hildesheim, Germany Phone: +49-5121-206917-0 | Fax: +49-5121-206917-9 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Generic MMC-over-SPI binding? 2008-01-08 16:11 ` Robert Schwebel @ 2008-01-08 16:29 ` Simon Richter 0 siblings, 0 replies; 6+ messages in thread From: Simon Richter @ 2008-01-08 16:29 UTC (permalink / raw) To: Robert Schwebel; +Cc: linuxppc-dev, linuxppc-embedded Hi, Robert Schwebel wrote: > Or is your question how to express this in the device tree? This. As far as I can see, using the device tree for this is currently unsupported, and everyone who uses the mmc-spi driver just creates a platform device in the board startup code, which strikes me as somewhat redundant, so I think it might be good to move it into the device tree (after all, it is still a hardware device). Simon ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Generic MMC-over-SPI binding? 2008-01-08 14:22 Generic MMC-over-SPI binding? Simon Richter 2008-01-08 16:11 ` Robert Schwebel @ 2008-01-08 17:27 ` Arnd Bergmann 2008-01-09 17:17 ` Simon Richter 1 sibling, 1 reply; 6+ messages in thread From: Arnd Bergmann @ 2008-01-08 17:27 UTC (permalink / raw) To: linuxppc-dev; +Cc: linuxppc-embedded On Tuesday 08 January 2008, Simon Richter wrote: > in an embedded system similar to the lite5200 board, there is an MMC > card socket connected to one of the PSCs. Ideally, I'd like to express > this fact via the device tree and have the kernel bind the mmc-spi > driver to the SPI interface, but I cannot find any place where to insert > this code that I feel comfortable with. > ... > Any ideas? > One way you could do it would be to have an spi_board_info in the way that mpc832x_spi_init does it, but that would not make use of the device tree. What would probably be a better way is to call spi_new_device() from the mpc52xx_psc_spi driver, with an spi_board_info you generate on the fly for each child of the spi controller. The important part where this connects to the mmc-spi driver is that you need to set spi_board_info->modalias to "mmc-spi", if the device node can be identified as an mmc card. We'd have to define a list of valid identifications of SPI devices in the device tree, and teach the SPI drivers how they relate to linux device drivers like mmc-spi. Since that part of the code would be used by all device tree based SPI master drivers, it should be in a separate module, which can consist of a single exported function, like (paraphrased): void spi_of_scan_master(struct spi_master *master) { struct device_node *child; of_dev_for_each_child(master->dev->node, child) { struct spi_board_info *info; info = kzalloc(sizeof (*info), GFP_KERNEL); if (of_device_is_compatible(child, "spi,mmc")) strcpy(info->modalias, "mmc-spi"); else if (of_device_is_compatible(child, "spi,foo")) strcpy(info->modalias, "foo"); else strcpy(info->modalias, ""); info->irq = irq_of_parse_and_map(child); spi_new_device(master, child); } } Then you call that function after registering the master, from mpc52xx_psc_spi_of_probe. Arnd <>< ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Generic MMC-over-SPI binding? 2008-01-08 17:27 ` Arnd Bergmann @ 2008-01-09 17:17 ` Simon Richter 2008-01-09 21:55 ` Arnd Bergmann 0 siblings, 1 reply; 6+ messages in thread From: Simon Richter @ 2008-01-09 17:17 UTC (permalink / raw) To: linuxppc-dev, linuxppc-embedded Hi, Arnd Bergmann wrote: > The important part where this connects to the mmc-spi driver is that > you need to set spi_board_info->modalias to "mmc-spi", if the > device node can be identified as an mmc card. Doing that now, using the code you provided as a base. The SPI child device gets registered, but it appears something is still missing as no messages I could attribute to mmc-spi appear. My suspicion would be that it doesn't like the monolithic kernel for some reason (the mmc-spi driver registers itself as a driver called "mmc_spi", not sure if the modalias handling will catch that; still investigating there). > Then you call that function after registering the master, from > mpc52xx_psc_spi_of_probe. I've changed mpc52xx_psc_spi_do_probe to have an additional argument for the OF device node of the SPI master; ARCH=ppc can call this with NULL as long as it still exists. Simon ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Generic MMC-over-SPI binding? 2008-01-09 17:17 ` Simon Richter @ 2008-01-09 21:55 ` Arnd Bergmann 0 siblings, 0 replies; 6+ messages in thread From: Arnd Bergmann @ 2008-01-09 21:55 UTC (permalink / raw) To: linuxppc-dev; +Cc: linuxppc-embedded On Wednesday 09 January 2008, Simon Richter wrote: > > The important part where this connects to the mmc-spi driver is that > > you need to set spi_board_info->modalias to "mmc-spi", if the > > device node can be identified as an mmc card. > > Doing that now, using the code you provided as a base. The SPI child > device gets registered, but it appears something is still missing as no > messages I could attribute to mmc-spi appear. My suspicion would be that > it doesn't like the monolithic kernel for some reason (the mmc-spi > driver registers itself as a driver called "mmc_spi", not sure if the > modalias handling will catch that; still investigating there). Right, the modalias needs to be the same as the driver name, not the module name, so you should change it to mmc_spi as well. For loading the module it would not make a difference because - and _ are treated the same by the module loader, but the device only gets associated with the driver when it matches exactly. > > Then you call that function after registering the master, from > > mpc52xx_psc_spi_of_probe. > > I've changed mpc52xx_psc_spi_do_probe to have an additional argument for > the OF device node of the SPI master; ARCH=ppc can call this with NULL > as long as it still exists. Ok. keeping the code itself in the mpc52xx_psc_spi driver is fine as long as it's relatively small. Other of_platform_drivers for SPI will just have to it the same way. Arnd <>< ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-01-09 21:55 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-01-08 14:22 Generic MMC-over-SPI binding? Simon Richter 2008-01-08 16:11 ` Robert Schwebel 2008-01-08 16:29 ` Simon Richter 2008-01-08 17:27 ` Arnd Bergmann 2008-01-09 17:17 ` Simon Richter 2008-01-09 21:55 ` Arnd Bergmann
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox