linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Recommendations for a new MFD device driver?
@ 2015-02-06 10:10 Sascha Hauer
  2015-02-06 11:54 ` Mark Brown
  2015-02-10  7:20 ` Lee Jones
  0 siblings, 2 replies; 6+ messages in thread
From: Sascha Hauer @ 2015-02-06 10:10 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: linux-kernel, eddie.huang, Lee Jones, Mark Brown

Hi All,

We are adding support for a new pretty typical MFD device, the MediaTek
MT6397. Initial patches are already posted. It's a PMIC which among other
things has regulators and a RTC. The same RTC is reused on another PMIC,
but with another register offset and another interrupt.

Now the question is where shall we put the register/irq resource
information?

1) Put it into the RTC device driver.
2) Put it into the .resource field of struct mfd_cell
3) Put it into the device tree using standard reg, interrupt properties and
   a) Let the RTC driver interpret these
   b) Let the MFD driver create resources in the .resource field of struct
      mfd_cell
   c) Let the MFD core create the resources

I have a tendency to 3, but I'm afraid that the resource informations
are duplicated too much in the device tree source files, because every
user would have to carry a full description of the mfd device. Maybe
that duplication could be reduced with some CPP magic, I don't know.

Maybe this is a solved problem and I'm just not picking a good example
from drivers/mfd.

Any thoughts?

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Recommendations for a new MFD device driver?
  2015-02-06 10:10 Recommendations for a new MFD device driver? Sascha Hauer
@ 2015-02-06 11:54 ` Mark Brown
  2015-02-06 12:55   ` Yingjoe Chen
  2015-02-10  7:20 ` Lee Jones
  1 sibling, 1 reply; 6+ messages in thread
From: Mark Brown @ 2015-02-06 11:54 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: linux-arm-kernel, linux-kernel, eddie.huang, Lee Jones

[-- Attachment #1: Type: text/plain, Size: 1135 bytes --]

On Fri, Feb 06, 2015 at 11:10:06AM +0100, Sascha Hauer wrote:

> 1) Put it into the RTC device driver.
> 2) Put it into the .resource field of struct mfd_cell
> 3) Put it into the device tree using standard reg, interrupt properties and
>    a) Let the RTC driver interpret these
>    b) Let the MFD driver create resources in the .resource field of struct
>       mfd_cell
>    c) Let the MFD core create the resources

> I have a tendency to 3, but I'm afraid that the resource informations
> are duplicated too much in the device tree source files, because every
> user would have to carry a full description of the mfd device. Maybe
> that duplication could be reduced with some CPP magic, I don't know.

> Maybe this is a solved problem and I'm just not picking a good example
> from drivers/mfd.

The wm831x drivers take option 2 but are pre-DT, it still seems the most
sensible thing to me though - no need for the user to have to repeat
this information in every DT and easy to add new stuff if we need it.
You could use a .dtsi like we use for SoCs to reduce the duplication
required if you do decide to put things in the DT.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Recommendations for a new MFD device driver?
  2015-02-06 11:54 ` Mark Brown
@ 2015-02-06 12:55   ` Yingjoe Chen
  2015-02-06 13:52     ` Mark Brown
  0 siblings, 1 reply; 6+ messages in thread
From: Yingjoe Chen @ 2015-02-06 12:55 UTC (permalink / raw)
  To: Mark Brown, Sascha Hauer
  Cc: eddie.huang, Lee Jones, linux-kernel, linux-arm-kernel

On Fri, 2015-02-06 at 11:54 +0000, Mark Brown wrote:
> On Fri, Feb 06, 2015 at 11:10:06AM +0100, Sascha Hauer wrote:
> 
> > 1) Put it into the RTC device driver.
> > 2) Put it into the .resource field of struct mfd_cell
> > 3) Put it into the device tree using standard reg, interrupt properties and
> >    a) Let the RTC driver interpret these
> >    b) Let the MFD driver create resources in the .resource field of struct
> >       mfd_cell
> >    c) Let the MFD core create the resources
> 
> > I have a tendency to 3, but I'm afraid that the resource informations
> > are duplicated too much in the device tree source files, because every
> > user would have to carry a full description of the mfd device. Maybe
> > that duplication could be reduced with some CPP magic, I don't know.
> 
> > Maybe this is a solved problem and I'm just not picking a good example
> > from drivers/mfd.
> 
> The wm831x drivers take option 2 but are pre-DT, it still seems the most
> sensible thing to me though - no need for the user to have to repeat
> this information in every DT and easy to add new stuff if we need it.
> You could use a .dtsi like we use for SoCs to reduce the duplication
> required if you do decide to put things in the DT.

Hi,

I think we should create a dtsi file, say mt6397.dtsi, the regulator
device nodes are already too much to duplicate into every board using
mt6397.

But a new problem is where should we put it? MT6397 is used in both
mt8135-evbp1(armv7) & mt8173-evb(armv8) boards, so they both need
mt6397.dtsi. Should we put them in include/dt-bindings to avoid
duplicate it into both arch/arm/boot/dts and arch/arm64/boot/dts?

Joe.C




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Recommendations for a new MFD device driver?
  2015-02-06 12:55   ` Yingjoe Chen
@ 2015-02-06 13:52     ` Mark Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2015-02-06 13:52 UTC (permalink / raw)
  To: Yingjoe Chen
  Cc: Sascha Hauer, eddie.huang, Lee Jones, linux-kernel, linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 728 bytes --]

On Fri, Feb 06, 2015 at 08:55:12PM +0800, Yingjoe Chen wrote:

> I think we should create a dtsi file, say mt6397.dtsi, the regulator
> device nodes are already too much to duplicate into every board using
> mt6397.

Please bear in mind that the regulator bindings are all about what is
being done to connect the PMIC to the rest of the system on a given
board; this means that it is almost always a bad idea to have a generic
include file for the PMIC since while many boards may be similar other
boards may differ and it's potentially unsafe to try to handle things
generally.  

It can be a good idea to have a .dsti file for the common elements of a
widely used reference design but that's a different thing.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Recommendations for a new MFD device driver?
  2015-02-06 10:10 Recommendations for a new MFD device driver? Sascha Hauer
  2015-02-06 11:54 ` Mark Brown
@ 2015-02-10  7:20 ` Lee Jones
  2015-02-11  9:42   ` Sascha Hauer
  1 sibling, 1 reply; 6+ messages in thread
From: Lee Jones @ 2015-02-10  7:20 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: linux-arm-kernel, linux-kernel, eddie.huang, Mark Brown

On Fri, 06 Feb 2015, Sascha Hauer wrote:

> Hi All,
> 
> We are adding support for a new pretty typical MFD device, the MediaTek
> MT6397. Initial patches are already posted. It's a PMIC which among other
> things has regulators and a RTC. The same RTC is reused on another PMIC,
> but with another register offset and another interrupt.
> 
> Now the question is where shall we put the register/irq resource
> information?
> 
> 1) Put it into the RTC device driver.
> 2) Put it into the .resource field of struct mfd_cell
> 3) Put it into the device tree using standard reg, interrupt properties and
>    a) Let the RTC driver interpret these
>    b) Let the MFD driver create resources in the .resource field of struct
>       mfd_cell
>    c) Let the MFD core create the resources

I have no problem with 2, if that's the route you'd like to take.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Recommendations for a new MFD device driver?
  2015-02-10  7:20 ` Lee Jones
@ 2015-02-11  9:42   ` Sascha Hauer
  0 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2015-02-11  9:42 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-arm-kernel, linux-kernel, eddie.huang, Mark Brown

On Tue, Feb 10, 2015 at 03:20:39PM +0800, Lee Jones wrote:
> On Fri, 06 Feb 2015, Sascha Hauer wrote:
> 
> > Hi All,
> > 
> > We are adding support for a new pretty typical MFD device, the MediaTek
> > MT6397. Initial patches are already posted. It's a PMIC which among other
> > things has regulators and a RTC. The same RTC is reused on another PMIC,
> > but with another register offset and another interrupt.
> > 
> > Now the question is where shall we put the register/irq resource
> > information?
> > 
> > 1) Put it into the RTC device driver.
> > 2) Put it into the .resource field of struct mfd_cell
> > 3) Put it into the device tree using standard reg, interrupt properties and
> >    a) Let the RTC driver interpret these
> >    b) Let the MFD driver create resources in the .resource field of struct
> >       mfd_cell
> >    c) Let the MFD core create the resources
> 
> I have no problem with 2, if that's the route you'd like to take.

Ok, thanks Lee and Mark for the input. I think we should go with option
2 then. While it's convenient to put the resources into the device tree
in the first place, it probably becomes cumbersome when Linux gets a
different idea how the subdevices of the PMIC should be arranged.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-02-11  9:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-06 10:10 Recommendations for a new MFD device driver? Sascha Hauer
2015-02-06 11:54 ` Mark Brown
2015-02-06 12:55   ` Yingjoe Chen
2015-02-06 13:52     ` Mark Brown
2015-02-10  7:20 ` Lee Jones
2015-02-11  9:42   ` Sascha Hauer

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).