linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
	Hans Verkuil <hverkuil@xs4all.nl>,
	Sylwester Nawrocki <s.nawrocki@samsung.com>,
	Sylwester Nawrocki <sylvester.nawrocki@gmail.com>,
	linux-media@vger.kernel.org, devicetree-discuss@lists.ozlabs.org,
	Magnus Damm <magnus.damm@gmail.com>,
	linux-sh@vger.kernel.org,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	Stephen Warren <swarren@wwwdotorg.org>,
	Arnd Bergmann <arnd@arndb.de>,
	Grant Likely <grant.likely@secretlab.ca>
Subject: Re: [PATCH 05/14] media: add a V4L2 OF parser
Date: Wed, 10 Oct 2012 11:57:03 -0300	[thread overview]
Message-ID: <20121010115703.7a72fdd1@redhat.com> (raw)
In-Reply-To: <1909082.6p5inUAuOH@avalon>

Em Wed, 10 Oct 2012 16:48 +0200
Laurent Pinchart <laurent.pinchart@ideasonboard.com> escreveu:

> Hi Mauro,
> 
> On Wednesday 10 October 2012 10:45:22 Mauro Carvalho Chehab wrote:
> > Em Wed, 10 Oct 2012 14:54 +0200 Laurent Pinchart escreveu:
> > > > Also, ideally OF-compatible (I2C) drivers should run with no platform
> > > > data, but soc-camera is using I2C device platform data intensively. To
> > > > avoid modifying the soc-camera core and all drivers, I also trigger on
> > > > the
> > > > BUS_NOTIFY_BIND_DRIVER event and assign a reference to the dynamically
> > > > created platform data to the I2C device. Would we also want to do this
> > > > for
> > > > all V4L2 bridge drivers? We could call this a "prepare" callback or
> > > > something similar...
> > > 
> > > If that's going to be an interim solution only I'm fine with keeping it in
> > > soc-camera.
> > 
> > I'm far from being an OF expert, but why do we need to export I2C devices to
> > DT/OF? On my understanding, it is the bridge code that should be
> > responsible for detecting, binding and initializing the proper I2C devices.
> > On several cases, it is impossible or it would cause lots of ugly hacks if
> > we ever try to move away from platform data stuff, as only the bridge
> > driver knows what initialization is needed for an specific I2C driver.
> 
> In a nutshell, a DT-based platform doesn't have any board code (except in rare 
> cases, but let's not get into that), and thus doesn't pass any platform data 
> structure to drivers. However, drivers receive a DT node, which contains a 
> hierarchical description of the hardware, and parse those to extract 
> information necessary to configure the device.
> 
> One very important point to keep in mind here is that the DT is not Linux-
> specific. DT bindings are designed to be portable, and thus must only contain 
> hardware descriptions, without any OS-specific information or policy 
> information. For instance information such as the maximum video buffers size 
> is not allowed in the DT.
> 
> The DT is used both to provide platform data to drivers and to instantiate 
> devices. I2C device DT nodes are stored as children of the I2C bus master DT 
> node, and are automatically instantiated by the I2C bus master. This is a 
> significant change compared to our current situation where the V4L2 bridge 
> driver receives an array of I2C board information structures and instatiates 
> the devices itself. Most of the DT support work will go in supporting that new 
> instantiation mechanism. The bridge driver doesn't control instantiation of 
> the I2C devices anymore, but need to bind with them at runtime.
> 
> > To make things more complex, it is expected that most I2C drivers to be arch
> > independent, and they should be allowed to be used by a personal computer
> > or by an embedded device.
> 
> Agreed. That's why platform data structures won't go away anytime soon, a PCI 
> bridge driver for hardware that contain I2C devices will still instantiate the 
> I2C devices itself. We don't plan to or even want to get rid of that 
> mechanism, as there are perfectly valid use cases. However, for DT-based 
> embedded platforms, we need to support a new instantiation mechanism.
> 
> > Let me give 2 such examples:
> > 
> > 	- ir-i2c-kbd driver supports lots of IR devices. Platform_data is needed
> > to specify what hardware will actually be used, and what should be the
> > default Remote Controller keymap;
> 
> That driver isn't used on embedded platforms so it doesn't need to be changed 
> now.
> 
> > 	- Sensor drivers like ov2940 is needed by soc_camera and by other
> > webcam drivers like em28xx. The setup for em28xx should be completely
> > different than the one for soc_camera: the initial registers init sequence
> > is different for both. As several registers there aren't properly
> > documented, there's no easy way to parametrize the configuration.
> 
> Such drivers will need to support both DT-based platform data and structure-
> based platform data. They will likely parse the DT node and fill a platform 
> data structure, to avoid duplicating initialization code.
> 
> Please note that the new subdevs instantiation mechanism needed for DT will 
> need to handle any instantiation order, as we can't guarantee the I2C device 
> and bridge device instantiation order with DT. It should thus then support the 
> current instantiation order we use for PCI and USB platforms.
> 
> > So, for me, we should not expose the I2C devices directly on OF; it should,
> > instead, see just the bridge, and let the bridge to map the needed I2C
> > devices using the needed platform_data.
> 
> We can't do that, there will be no platform data anymore with DT-based 
> platforms.
> 
> As a summary, platform data structures won't go away, I2C drivers that need to 
> work both on DT-based and non-DT-based platforms will need to support both the 
> DT and platform data structures to get platform data. PCI and USB bridges will 
> still instantiate their I2C devices, and binding between the I2C devices and 
> the bridge can either be handled with two different instantiation mechanisms 
> (the new one for DT platforms, with runtime bindings, and the existing one for 
> non-DT platforms, with binding at instantiation time) or move to a single 
> runtime binding mechanism. It's too early to know which solution will be 
> simpler.
> 

It seems that you're designing a Frankstein monster with DT/OF and I2C.

Increasing each I2C driver code to support both platform_data and DT way
of doing things seems a huge amount of code that will be added, and I really
fail to understand why this is needed, in the first place.

Ok, I understand that OF specs are OS-independent, but I suspect that
they don't dictate how things should be wired internally at the OS.

So, if DT/OF is so restrictive, and require its own way of doing things, 
instead of changing everything with the risks of adding (more) regressions
to platform drivers, why don't just create a shell driver that will
encapsulate DT/OF specific stuff into the platform_data?

Regards,
Mauro

  reply	other threads:[~2012-10-10 14:57 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1348754853-28619-1-git-send-email-g.liakhovetski@gmx.de>
     [not found] ` <1348754853-28619-6-git-send-email-g.liakhovetski@gmx.de>
2012-10-01 21:37   ` [PATCH 05/14] media: add a V4L2 OF parser Sylwester Nawrocki
2012-10-02  9:49     ` Guennadi Liakhovetski
2012-10-02 10:13       ` Sylwester Nawrocki
2012-10-02 11:04         ` Guennadi Liakhovetski
2012-10-05 10:41         ` Hans Verkuil
2012-10-05 10:58           ` Guennadi Liakhovetski
2012-10-05 11:23             ` Hans Verkuil
2012-10-05 11:35               ` Guennadi Liakhovetski
2012-10-08 12:23               ` Guennadi Liakhovetski
2012-10-08 13:48                 ` Hans Verkuil
2012-10-08 14:30                   ` Guennadi Liakhovetski
2012-10-08 14:53                     ` Hans Verkuil
2012-10-08 15:15                       ` Guennadi Liakhovetski
2012-10-08 15:41                         ` Hans Verkuil
2012-10-08 15:53                           ` Guennadi Liakhovetski
2012-10-08 16:00                             ` Guennadi Liakhovetski
2012-10-10 13:22                           ` Laurent Pinchart
2012-10-10 13:18                         ` Laurent Pinchart
2012-10-10 16:50                           ` Stephen Warren
2012-10-10 22:51                             ` Laurent Pinchart
2012-10-11 16:15                               ` Stephen Warren
2012-10-10 13:12                       ` Laurent Pinchart
2012-10-10 12:54                 ` Laurent Pinchart
2012-10-10 13:45                   ` Mauro Carvalho Chehab
2012-10-10 14:48                     ` Laurent Pinchart
2012-10-10 14:57                       ` Mauro Carvalho Chehab [this message]
2012-10-10 15:15                         ` Laurent Pinchart
2012-10-11 19:48                 ` Sakari Ailus
2012-10-13  0:16                   ` Guennadi Liakhovetski
2012-10-05 18:30             ` Sylwester Nawrocki
2012-10-05 18:45               ` Mark Brown
2012-10-08  9:40               ` Guennadi Liakhovetski
2012-10-09 10:34                 ` Sylwester Nawrocki
2012-10-09 11:00                   ` Hans Verkuil
2012-10-10 13:25                     ` Laurent Pinchart
2012-10-10 20:23                       ` Sylwester Nawrocki
2012-10-10 20:32                         ` Guennadi Liakhovetski
2012-10-10 21:12                           ` Sylwester Nawrocki
2012-10-10 23:05                           ` Laurent Pinchart
2012-10-10 22:58                         ` Laurent Pinchart
2012-10-08 21:30             ` Laurent Pinchart
2012-10-08 10:03   ` Sylwester Nawrocki
     [not found] ` <1348754853-28619-5-git-send-email-g.liakhovetski@gmx.de>
2012-10-01 20:45   ` [PATCH 04/14] media: add V4L2 DT binding documentation Sylwester Nawrocki
2012-10-02 14:15   ` Rob Herring
2012-10-02 14:33     ` Guennadi Liakhovetski
2012-10-03 20:54       ` Rob Herring
2012-10-05  9:43         ` Guennadi Liakhovetski
2012-10-05 11:31           ` Hans Verkuil
2012-10-05 11:37             ` Guennadi Liakhovetski
2012-10-08 20:00       ` Stephen Warren
2012-10-08 21:00         ` Laurent Pinchart
2012-10-08 21:14           ` Guennadi Liakhovetski
2012-10-09  9:21             ` Hans Verkuil
2012-10-09  9:29               ` Guennadi Liakhovetski
2012-10-05 15:10   ` Sascha Hauer
2012-10-05 15:41     ` Guennadi Liakhovetski
2012-10-05 16:02       ` Sascha Hauer
2012-10-08  7:58         ` Guennadi Liakhovetski
2012-10-10  8:40           ` Sascha Hauer
2012-10-10  8:51             ` Mark Brown
2012-10-10  9:21               ` Sascha Hauer
2012-10-10 10:46                 ` Mark Brown
2012-10-08 20:12   ` Stephen Warren
2012-10-05 12:32 ` [PATCH 00/14] V4L2 DT support Sylwester Nawrocki
2012-10-05 14:41   ` Guennadi Liakhovetski
     [not found] ` <1348754853-28619-11-git-send-email-g.liakhovetski@gmx.de>
2012-10-05 19:11   ` [PATCH 10/14] media: soc-camera: support OF cameras Sylwester Nawrocki
2012-10-08  8:37     ` Guennadi Liakhovetski
2012-10-08  9:28       ` Sylwester Nawrocki
2013-04-08  9:19   ` Barry Song
2013-04-08 11:21     ` Guennadi Liakhovetski
2013-04-08 11:49       ` Barry Song
     [not found] ` <1348754853-28619-8-git-send-email-g.liakhovetski@gmx.de>
2013-04-10 10:38   ` [PATCH 07/14] media: soc-camera: support deferred probing of clients Barry Song
2013-04-10 12:06     ` Guennadi Liakhovetski
2013-04-10 13:53       ` Barry Song
2013-04-10 13:56         ` Mark Brown
2013-04-10 14:00           ` Barry Song
2013-04-10 14:03         ` Guennadi Liakhovetski
2013-04-10 14:30           ` Barry Song
2013-04-10 14:43             ` Guennadi Liakhovetski
2013-04-10 15:02               ` Barry Song

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=20121010115703.7a72fdd1@redhat.com \
    --to=mchehab@redhat.com \
    --cc=arnd@arndb.de \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=g.liakhovetski@gmx.de \
    --cc=grant.likely@secretlab.ca \
    --cc=hverkuil@xs4all.nl \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=s.nawrocki@samsung.com \
    --cc=swarren@wwwdotorg.org \
    --cc=sylvester.nawrocki@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).