All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: linuxppc-dev@ozlabs.org
Cc: Milton Miller <miltonm@bga.com>
Subject: Re: SPI devices and OF
Date: Thu, 5 Apr 2007 21:52:20 +0200	[thread overview]
Message-ID: <200704052152.21082.arnd@arndb.de> (raw)
In-Reply-To: <20070405191145.GA20139@himalia.labnet.pengutronix.de>

On Thursday 05 April 2007, Sascha Hauer wrote:
> Not a problem of programming technique but a problem of where to
> actually get the information in the platform from. device tree or
> board setup code?

There should not need to be board specific setup code in many cases,
so it should be in the device tree.

> > You kzalloc the
> > data structure that the device needs, fill it in, and fill out
> > the pointer in the auto _info variable that gets copied by
> > register_new_device.
>=20
> My point is that we have two possibilities to handle spi devices. a) We
> put the information about all devices connected to a spi bus into the
> device tree in which case we must also put the data described in the
> platform_data (e.g. the mentioned page_size for at25 eeproms) into the
> tree. b) would be to put only the spi masters into the tree (well they
> already are).

If all the information you need can be probed through SPI commands, you
don't need to have a device tree layout for it. That is how we deal
with PCI devices as well. However, if there are things you need to know
in the specific driver for an SPI attached device, it should be in
the tree.

> It seems b) is the prefered way. If I understand Ben correctly I can
> then put some proprietary tag into the tree to differentiate between
> different spi controllers so that the board code knows which spi
> controller is which. So my tree could look like:
>=20
> spi@f00 {
> =A0=A0=A0=A0=A0=A0=A0=A0device_type =3D "spi";
> =A0=A0=A0=A0=A0=A0=A0=A0compatible =3D "mpc5200b-spi\0mpc5200-spi";
> =A0=A0=A0=A0=A0=A0=A0=A0reg =3D <f00 20>;
> =A0=A0=A0=A0=A0=A0=A0=A0interrupts =3D <2 d 0 2 e 0>;
> =A0=A0=A0=A0=A0=A0=A0=A0interrupt-parent =3D <500>;
> =A0=A0=A0=A0=A0=A0=A0=A0identifier =3D <0>;
> }
>=20
> spi@xxx {
> =A0=A0=A0=A0=A0=A0=A0=A0device_type =3D "spi";
> =A0=A0=A0=A0=A0=A0=A0=A0...
> =A0=A0=A0=A0=A0=A0=A0=A0identifier =3D <1>;
> }
>=20
> I can then use the board code to populate the spi devices depending on
> the identifier. Perhaps there is a better name instead of 'identifier'?

I think this is backwards. The board code should not need to know
about it, but you identify the chip select based on the "compatible"
property. Your of_platform_driver probe will then look more or less like
this:

struct of_device_id of_spi_ids[] =3D {
	{ .type =3D "spi", .compatible =3D "mpc5200b-spi",
			 .data =3D SPI_PROBE_MPC5200b },
	{ .type =3D "spi", .compatible =3D "mpc52foo-spi",
			 .data =3D SPI_PROBE_MPC52FOO },
	...
};

static int of_spi_probe(struct of_device* dev,
	const struct of_device_id *match)
{
	int ret;

	/* common initialization */
	...

	/* board specific initialition */
	switch (match->data) {
	case SPI_PROBE_MPC5200b:
		ret =3D of_spi_probe_mpc5200b(dev);
		break;
	case SPI_PROBE_MPC5200b:
		ret =3D of_spi_probe_mpc5200b(dev);
		break;
	...
	}
=09
	/* register with spi layer */
	...

	return ret;
}

	Arnd <><

      reply	other threads:[~2007-04-05 19:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-04 11:09 SPI devices and OF Sascha Hauer
2007-04-04 11:51 ` Vitaly Wool
2007-04-04 16:34   ` Kumar Gala
2007-04-04 17:03     ` Arnd Bergmann
2007-04-04 17:12       ` Kumar Gala
2007-04-05  7:32         ` Benjamin Herrenschmidt
2007-04-05 15:00           ` Milton Miller
2007-04-05  8:33     ` Sascha Hauer
2007-04-04 15:57 ` Milton Miller
2007-04-05  8:50   ` Sascha Hauer
2007-04-05 14:44     ` Milton Miller
2007-04-05 19:11       ` Sascha Hauer
2007-04-05 19:52         ` Arnd Bergmann [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=200704052152.21082.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=miltonm@bga.com \
    /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.