All of lore.kernel.org
 help / color / mirror / Atom feed
From: Javier Martinez Canillas <martinez.javier@gmail.com>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: "Javier Martinez Canillas" <javier.martinez@collabora.co.uk>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Tony Lindgren" <tony@atomide.com>,
	"Benoît Cousson" <b-cousson@ti.com>,
	"Linus Walleij" <linus.walleij@linaro.org>,
	"Enric Balletbo i Serra" <eballetbo@gmail.com>,
	"Ezequiel Garcia" <ezequiel.garcia@free-electrons.com>,
	devicetree-discuss@lists.ozlabs.org, linux-omap@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	"Grant Likely" <grant.likely@secretlab.ca>
Subject: Re: [PATCH RFC 1/7] platform: add a device node
Date: Sun, 10 Feb 2013 12:35:43 +0100	[thread overview]
Message-ID: <CAAwP0s0fCJmUfTJweGhXj5bXsQ0Gov9JbUJtqYMwL7duNLZv_Q@mail.gmail.com> (raw)
In-Reply-To: <20130210093708.GL17852@n2100.arm.linux.org.uk>

On Sun, Feb 10, 2013 at 10:37 AM, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
> On Sun, Feb 10, 2013 at 02:49:21AM +0100, Javier Martinez Canillas wrote:
>> I knew this would be controversial and that's why I didn't mean it to be a patch
>> but a RFC :)
>>
>> The problem basically is that you have to associate the platform device with its
>> corresponding DT device node because it can be used in the driver probe function.
>
> When DT is being used, doesn't DT create the platform devices for you,
> with the device node already set correctly?
>

Well they usually do but not always just like usually you have a
platform_device in your board code and call platform_device_register().

But in some configurations you can't just define the platform_device
required resources (I/O memory, IRQ, etc) as static platform data.
In some cases you need a level of indirection.

In this particular case a SMSC ethernet chip is connected to an
OMAP3 processor through its General-Purpose Memory Controller.

You can't just define the I/O memory used by the device since you first
need to request that address to the GPMC. The same happens with the
IRQ line since a OMAP GPIO pin is used so you have to first configure
the GPIO line as input.

So in platform code you call to gpmc_smsc911x_init() passing all the
GPMC specific configurations (GPIO used for IRQ, GPMC chip select, etc)

Then gpmc_smsc911x_init() does all the needed setup, fills a platform_data
for the real platform_device and calls  platform_device_register_resndata().

>From the smsc911x platform_driver probe function point of view it just have
resources and doesn't know if it's I/O memory is directly mapped or is
through a memory controller as the GPMC. It also doesn't know if the IRQ is
a GPIO or not.

Another approach could be extending the current SMSC LAN DT binding with
GPMC-specific properties so the platform driver could do this setup when the
device node is found and the probe function is called.

> Manually creating platform devices and adding DT nodes to it sounds like
> the wrong thing to be doing.
> --

Yes, I don't like this approach to much either but I didn't find a better way to
do it. That was the main point of this RFC.

I'm still learning about Device Trees so I hope that someone with more
experience with DT or more familiarized with OMAP GPMC and the SMSC
driver could take a step forward and help me giving a better idea.

Thanks a lot for your feedback and best regards,
Javier

WARNING: multiple messages have this Message-ID (diff)
From: martinez.javier@gmail.com (Javier Martinez Canillas)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH RFC 1/7] platform: add a device node
Date: Sun, 10 Feb 2013 12:35:43 +0100	[thread overview]
Message-ID: <CAAwP0s0fCJmUfTJweGhXj5bXsQ0Gov9JbUJtqYMwL7duNLZv_Q@mail.gmail.com> (raw)
In-Reply-To: <20130210093708.GL17852@n2100.arm.linux.org.uk>

On Sun, Feb 10, 2013 at 10:37 AM, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
> On Sun, Feb 10, 2013 at 02:49:21AM +0100, Javier Martinez Canillas wrote:
>> I knew this would be controversial and that's why I didn't mean it to be a patch
>> but a RFC :)
>>
>> The problem basically is that you have to associate the platform device with its
>> corresponding DT device node because it can be used in the driver probe function.
>
> When DT is being used, doesn't DT create the platform devices for you,
> with the device node already set correctly?
>

Well they usually do but not always just like usually you have a
platform_device in your board code and call platform_device_register().

But in some configurations you can't just define the platform_device
required resources (I/O memory, IRQ, etc) as static platform data.
In some cases you need a level of indirection.

In this particular case a SMSC ethernet chip is connected to an
OMAP3 processor through its General-Purpose Memory Controller.

You can't just define the I/O memory used by the device since you first
need to request that address to the GPMC. The same happens with the
IRQ line since a OMAP GPIO pin is used so you have to first configure
the GPIO line as input.

So in platform code you call to gpmc_smsc911x_init() passing all the
GPMC specific configurations (GPIO used for IRQ, GPMC chip select, etc)

Then gpmc_smsc911x_init() does all the needed setup, fills a platform_data
for the real platform_device and calls  platform_device_register_resndata().

>From the smsc911x platform_driver probe function point of view it just have
resources and doesn't know if it's I/O memory is directly mapped or is
through a memory controller as the GPMC. It also doesn't know if the IRQ is
a GPIO or not.

Another approach could be extending the current SMSC LAN DT binding with
GPMC-specific properties so the platform driver could do this setup when the
device node is found and the probe function is called.

> Manually creating platform devices and adding DT nodes to it sounds like
> the wrong thing to be doing.
> --

Yes, I don't like this approach to much either but I didn't find a better way to
do it. That was the main point of this RFC.

I'm still learning about Device Trees so I hope that someone with more
experience with DT or more familiarized with OMAP GPMC and the SMSC
driver could take a step forward and help me giving a better idea.

Thanks a lot for your feedback and best regards,
Javier

  reply	other threads:[~2013-02-10 11:35 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-09 20:44 [PATCH RFC 0/7] ARM: OMAP: add DT binding for gpmc-smsc911x Javier Martinez Canillas
2013-02-09 20:44 ` Javier Martinez Canillas
2013-02-09 20:44 ` [PATCH RFC 1/7] platform: add a device node Javier Martinez Canillas
2013-02-09 20:44   ` Javier Martinez Canillas
2013-02-10  1:02   ` Greg Kroah-Hartman
2013-02-10  1:02     ` Greg Kroah-Hartman
2013-02-10  1:49     ` Javier Martinez Canillas
2013-02-10  1:49       ` Javier Martinez Canillas
2013-02-10  9:37       ` Russell King - ARM Linux
2013-02-10  9:37         ` Russell King - ARM Linux
2013-02-10 11:35         ` Javier Martinez Canillas [this message]
2013-02-10 11:35           ` Javier Martinez Canillas
2013-02-11  8:16           ` Sascha Hauer
2013-02-11  8:16             ` Sascha Hauer
2013-02-11 10:33             ` Javier Martinez Canillas
2013-02-11 10:33               ` Javier Martinez Canillas
2013-02-11 11:24               ` Sascha Hauer
2013-02-11 11:24                 ` Sascha Hauer
2013-02-11 11:38                 ` Javier Martinez Canillas
2013-02-11 11:38                   ` Javier Martinez Canillas
2013-02-18 13:51           ` Grant Likely
2013-02-18 13:51             ` Grant Likely
2013-02-18 13:56             ` Javier Martinez Canillas
2013-02-18 13:56               ` Javier Martinez Canillas
2013-02-18 13:33         ` Grant Likely
2013-02-18 13:33           ` Grant Likely
2013-02-09 20:44 ` [PATCH RFC 2/7] net: smsc911x: add pinctrl support Javier Martinez Canillas
2013-02-09 20:44   ` Javier Martinez Canillas
2013-02-11 14:23   ` Linus Walleij
2013-02-11 14:23     ` Linus Walleij
2013-02-11 14:29     ` Javier Martinez Canillas
2013-02-11 14:29       ` Javier Martinez Canillas
2013-02-09 20:44 ` [PATCH RFC 3/7] ARM: OMAP: gpmc-smsc911x: add DT dev node init function Javier Martinez Canillas
2013-02-09 20:44   ` Javier Martinez Canillas
2013-02-11 10:30   ` Mark Rutland
2013-02-11 10:30     ` Mark Rutland
2013-02-11 10:40     ` Javier Martinez Canillas
2013-02-11 10:40       ` Javier Martinez Canillas
2013-02-09 20:44 ` [PATCH RFC 4/7] ARM: OMAP: gpmc-smsc911x: pass a dev node to platform registration Javier Martinez Canillas
2013-02-09 20:44   ` Javier Martinez Canillas
2013-02-09 20:44 ` [PATCH RFC 5/7] ARM: OMAP: gpmc: add support for gpmc-smsc911x child nodes Javier Martinez Canillas
2013-02-09 20:44   ` Javier Martinez Canillas
2013-02-09 20:44 ` [PATCH RFC 6/7] ARM: dts: OMAP: Add an GPMC node for OMAP3 Javier Martinez Canillas
2013-02-09 20:44   ` Javier Martinez Canillas
2013-02-09 20:44 ` [PATCH RFC 7/7] ARM: dts: omap3-igep0020: Add SMSC911x LAN chip support Javier Martinez Canillas
2013-02-09 20:44   ` Javier Martinez Canillas

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=CAAwP0s0fCJmUfTJweGhXj5bXsQ0Gov9JbUJtqYMwL7duNLZv_Q@mail.gmail.com \
    --to=martinez.javier@gmail.com \
    --cc=b-cousson@ti.com \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=eballetbo@gmail.com \
    --cc=ezequiel.garcia@free-electrons.com \
    --cc=grant.likely@secretlab.ca \
    --cc=gregkh@linuxfoundation.org \
    --cc=javier.martinez@collabora.co.uk \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=tony@atomide.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.