Re: [PATCH v8 1/7] mfd: Add core driver for Nuvoton NCT6694
From: Lee Jones
Date: Thu Apr 10 2025 - 04:25:24 EST
On Mon, 07 Apr 2025, Ming Yu wrote:
> Lee Jones <lee@xxxxxxxxxx> 於 2025年4月4日 週五 下午10:21寫道:
> >
> > > ...
> > > > > > > + MFD_CELL_BASIC("gpio-nct6694", NULL, NULL, 0, 0x1),
> > > > > >
> > > > > > IDs are usually given in base-10.
> > > > > >
> > > > >
> > > > > Fix it in v9.
> > > > >
> > > > > > Why are you manually adding the device IDs?
> > > > > >
> > > > > > PLATFORM_DEVID_AUTO doesn't work for you?
> > > > > >
> > > > >
> > > > > I need to manage these IDs to ensure that child devices can be
> > > > > properly utilized within their respective modules.
> > > >
> > > > How? Please explain.
> > > >
> > > > This numbering looks sequential and arbitrary.
> > > >
> > > > What does PLATFORM_DEVID_AUTO do differently such that it is not useful?
> > > >
> > >
> > > As far as I know, PLATFORM_DEVID_AUTO assigns dynamic IDs to devices,
> > > but I need fixed IDs.
> > > For example, the GPIO driver relies on these IDs to determine the
> > > group, allowing the firmware to identify which GPIO group to operate
> > > on through the API.
> >
> > PLATFORM_DEVID_AUTO will allocate IDs 0 through 16, the same as you've
> > done here. These lines do not have any differentiating attributes, so
> > either way we are not allocating specific IDs to specific pieces of the
> > H/W. I still do not understand why you need to allocate them manually.
> >
>
> I'm using PLATFORM_DEVID_AUTO to allocate child device IDs with
> MFD_CELL_NAME(), like this:
>
> static const struct mfd_cell nct6694_dev[] = {
> MFD_CELL_NAME("nct6694-gpio"),
> MFD_CELL_NAME("nct6694-gpio"),
> ......
> MFD_CELL_NAME("nct6694-gpio"),
> MFD_CELL_NAME("nct6694-i2c"),
> MFD_CELL_NAME("nct6694-i2c"),
> ......
> MFD_CELL_NAME("nct6694-i2c"),
> ......
> };
>
> For example, the device IDs retrieved in gpio-nct6694.c is 1~16, and
> i2c-nct6694.c is 17~22. Does this mean each driver should
> independently handle its dynamically assigned IDs?
> Additionally, I originally referred to cgbc-core.c with i2c-cgbc.c,
> and ab8500-core.c with pwm-ab8500.c for associating child devices. Do
> you think this approach is appropriate in my case?
Yes, if you _need_ the ranges to start from 0, then you will have to
call mfd_add_devices() separately on those ranges. Otherwise one range
will follow directly on to another range.
But wait, you're using mfd_add_hotplug_devices(), which means you are
using PLATFORM_DEVID_AUTO. So your .id values that you've added are
being ignored anyway. Thus, if you have tested that this works, you
don't need them anyway, right?
--
Lee Jones [李琼斯]