Re: [PATCH] firmware: vpd: Add an interface to read VPD value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Quoting Cheng-yi Chiang (2019-10-07 11:50:31)
> On Mon, Oct 7, 2019 at 11:35 PM Stephen Boyd <swboyd@xxxxxxxxxxxx> wrote:
> >
> > Quoting Cheng-yi Chiang (2019-10-07 06:58:41)
> > >
> > > Hi Guenter,
> > > Thanks for the quick review.
> > > I'll update accordingly in v2.
> >
> > I'd prefer this use the nvmem framework which already handles many of
> > the requirements discussed here. Implement an nvmem provider and figure
> > out how to wire that up to the kernel users. Also, please include a user
> > of the added support, otherwise it is impossible to understand how this
> > code is used.
> >
> Hi Stephen,
> Thanks for the suggestion.
> My usage is for Intel machine driver to read a string for speaker calibration.
> 
> https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/1838091/4/sound/soc/intel/boards/cml_rt1011_rt5682.c#325
> 
> Based on the comments in this thread, its usage would look like
> 
> #define DSM_CALIB_KEY "dsm_calib"
> static int load_calibration_data(struct cml_card_private *ctx) {
>           char *data = NULL;
>           int ret;
>           u32 value_len;
> 
>           /* Read calibration data from VPD. */
>           ret = vpd_attribute_read(1, DSM_CALIB_KEY,
>                                          (u8 **)&data, &value_len);
> 
>           /* Parsing of this string...*/
> }
> 
> It is currently pending on unmerged machine driver cml_rt1011_rt5682.c
> in ASoC so I can not post it for review for now.
> 
> As for nvmem approach, I looked into examples of nvmem usage, and have
> a rough idea how to do this.
> 
> 1) In vpd.c, as it parses key and value in the VPD section, add nvmem cell  with
> {
> .name=key,
> .offset=consumed,   // need some change in vpd_decodec.c to get the
> offset of value in the section.
> .bytes=value
> }
> Implement read function with vpd_section as context.
> 
> 2) In vpd.c, register an nvm_device using devm_nvmem_register in
> coreboot_driver's probe function vpd_probe.
> 
> 3) As my use case does not use device tree, it is hard for ASoC
> machine to access nvmem device. I am wondering if I can use
> nvm_cell_lookup so machine driver can find the nvmem device using a
> con_id. But currently the cell lookup API requires a matched device,
> which does not fit my usage because there will be different machine
> drivers requesting the value.
> I think I can still workaround this by adding the lookup table in
> machine driver. This would seem to be a bit weird because I found that
> most lookup table is added in provider side, not consumer side. Not
> sure if this is logically correct.

Maybe Srini has some input here. It looks like your main concern is
consumer to provider mapping?

> 
> IMO the nvmem approach would create more complexity to support this
> simple usage. Plus, the underlying assumption of accessing data with
> offset in a buffer does not fit well with the already parsed VPD
> values in a list of vpd_attrib_info. But if you strongly feel that
> this is a better approach I can work toward this.
> 

I'm not sure how an ACPI system like this would work because my exposure
to ACPI is extremely limited. I would expect there to be some sort of
firmware property indicating that an nvmem should be used and it's
provided by VPD or for firmware to parse VPD itself and put the
information into the ACPI table for this device.

Has either of those things been done? If it is a reference/property in
firmware then it should be possible to connect consumer devices like the
audio device you mention to VPD via the nvmem APIs with some changes to
the nvmem framework assuming there's an approach for nvmem in ACPI in
some "standard" way. 

I'd like to use nvmem for two reasons. First, it is a kernel framework
for reading non-volatile memories, which is fairly close to what VPD is
for. Second, it makes a standard, i.e. non-vpd/coreboot specific, API
that drivers can use to read memories. Of course in ASoC the machine
driver is already very platform specific, but the idea is to avoid
platform specific APIs so that drivers are loosely coupled with the rest
of the kernel. We shouldn't push against that goal by introducing more
platform specific APIs.

_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux