From: Liam Girdwood <lrg@kernel.org>
To: Eric Miao <eric.y.miao@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>, Pavel Machek <pavel@suse.cz>
Subject: Re: Fundamental Design Flaw of the Device Driver Model?
Date: Fri, 22 Aug 2008 12:17:02 +0100 [thread overview]
Message-ID: <1219403822.10949.29.camel@odin> (raw)
In-Reply-To: <f17812d70808212325m24f25518t5e8dd2fc5e7919b@mail.gmail.com>
On Fri, 2008-08-22 at 14:25 +0800, Eric Miao wrote:
> Fundamental Design Flaw of the Device Driver Model?
> ===================================================
>
> Sorry for the misleading subject, its purpose is to draw your attention :-)
> The ideas below are preliminary and I hope I'm not making serious mistakes
> here.
>
> This question has actually been around in my mind for several months, when
> I started to work on some devices with multiple functions. Specifically, a
> Power Management IC (PMIC in short in the following text) usually includes
> LEDs support (charging, indication...) audio, touch screen, power monitoring,
> LDOs, DC-DC bucks, and possibly some others.
>
> The initial two ideas came into my mind were:
>
> 1. separate the functions into multiple devices, write a driver for each
> of these devices
>
I've opted for this option with the WM8350 PMIC driver.
> This, however, creates many questions you have to face with:
>
> 1. on what bus shall these sub-devices be?
> ** this is the reason I choose to use "platform_device", at least they
> can reside on the platform_bus_type, thus platform_driver can be used
> for this sub-device
My WM8350 clients are all platform_devices too.
>
> 2. these devices are actually useless except for linking the sub-device
> to it's sub-device driver and of course, wasting memory. Normally in
> the driver, another dedicated device will be created. E.g. let's take
> a typical simple LED driver as an example:
>
They are not useless as most of my client devices _need_ some sort of
platform data to be passed on for their probe() e.g. my LED driver needs
to know it's brightness values, trigger etc. They also all need a PMIC
reference (passed in the platform_data) which they will need to call any
core PMIC functions e.g. chip read/write
>
> 3. Who should be the correct parent of these LED devices, the intermediate
> sub-device we created just now? Or the pmic device on the I2C bus?
> My answer is the the latter, obviously. However, writing code like:
>
> led_classdev_register(pdev->dev.parent, &led_cdev)
Fwiw, I've made the WM8350 I2C driver the parent. The I2C driver also
contains the core PMIC services e.g. IRQs, GPIO's, IO, etc
> A normal device layout would be:
>
> device specific
> virtual bus type
> |
> platform_bus_type i2c_bus_type | virtual devices
> | | | |
> (device) V V V V
> Platform BUS ---> I2C Controller ---> PMIC -+-> LED device (1)
> |
> +-> LED device (2)
> |
> +-> LED device (3)
> |
> +-> DC-DC Buck1
> |
> +-> DC-DC Buck2
> |
> +-> LDO1
> |
> +-> LDO2
> |
> +-> Backlight PWM1
> |
> +-> Backlight PWM2
> |
> ...
>
Ok, I basically have :-
Platform devices
| |
V V
Platform Bus --> I2C controller --> PMIC +-> LED1
+-> LED2
+-> Audio
+-> DCDC1
+-> Backlight
I originally had a PMIC bus (like above) but decided it was easier just
to use the existing kernel infrastructure. My I2C PMIC driver just
registers the client platform_devices when it probes.
Cheers
Liam
next prev parent reply other threads:[~2008-08-22 11:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-22 6:25 Eric Miao
2008-08-22 9:03 ` Pavel Machek
2008-08-22 9:32 ` Eric Miao
2008-08-22 11:29 ` pHilipp Zabel
2008-08-23 0:56 ` Eric Miao
2008-08-22 11:17 ` Liam Girdwood [this message]
2008-08-22 14:00 ` Stefan Richter
2008-08-22 14:33 ` Jon Smirl
2008-08-23 1:02 ` Eric Miao
2008-08-23 3:54 ` Jon Smirl
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=1219403822.10949.29.camel@odin \
--to=lrg@kernel.org \
--cc=eric.y.miao@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pavel@suse.cz \
/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
Powered by JetHome