Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1607565 > unrolled thread

Re: [PATCH 3/7] ath9k: Add support for reading the EEPROM data using the nvmem API

Started byAlban <albeu@free.fr>
First post2017-03-23 15:50 +0100
Last post2017-03-24 17:30 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH 3/7] ath9k: Add support for reading the EEPROM data  using the nvmem API Alban <albeu@free.fr> - 2017-03-23 15:50 +0100
    Re: [PATCH 3/7] ath9k: Add support for reading the EEPROM data using the nvmem API Christian Lamparter <chunkeey@googlemail.com> - 2017-03-24 17:30 +0100

#1607565 — Re: [PATCH 3/7] ath9k: Add support for reading the EEPROM data using the nvmem API

FromAlban <albeu@free.fr>
Date2017-03-23 15:50 +0100
SubjectRe: [PATCH 3/7] ath9k: Add support for reading the EEPROM data using the nvmem API
Message-ID<tocdP-3va-13@gated-at.bofh.it>

[Multipart message — attachments visible in raw view] — view raw

On Tue, 14 Mar 2017 00:53:55 +0100
Christian Lamparter <chunkeey@googlemail.com> wrote:

> On Monday, March 13, 2017 10:05:11 PM CET Alban wrote:
> > Currently SoC platforms use a firmware request to get the EEPROM data.
> > This is mostly a hack and rely on using a user-helper scripts which is
> > deprecated. A nicer alternative is to use the nvmem API which was
> > designed for this kind of task.
> > 
> > Furthermore we let CONFIG_ATH9K_AHB select CONFIG_NVMEM as such
> > devices will generally use this method for loading the EEPROM data.
> > 
> > Signed-off-by: Alban <albeu@free.fr>
> > ---
> > @@ -654,6 +656,25 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc,
> >  	if (ret)
> >  		return ret;
> >  
> > +	/* If the EEPROM hasn't been retrieved via firmware request
> > +	 * use the nvmem API insted.
> > +	 */
> > +	if (!ah->eeprom_blob) {
> > +		struct nvmem_cell *eeprom_cell;
> > +
> > +		eeprom_cell = nvmem_cell_get(ah->dev, "eeprom");
> > +		if (!IS_ERR(eeprom_cell)) {
> > +			ah->eeprom_data = nvmem_cell_read(
> > +				eeprom_cell, &ah->eeprom_size);
> > +			nvmem_cell_put(eeprom_cell);
> > +
> > +			if (IS_ERR(ah->eeprom_data)) {
> > +				dev_err(ah->dev, "failed to read eeprom");
> > +				return PTR_ERR(ah->eeprom_data);
> > +			}
> > +		}
> > +	}
> > +
> >  	if (ath9k_led_active_high != -1)
> >  		ah->config.led_active_high = ath9k_led_active_high == 1;
> >    
> Are you sure this works with AR93XX SoCs that have the calibration data
> in the OTP?

I only tested this on an ar9132 platform, so it might well be that a
few things are missing for the newer SoC. However this shouldn't break
anything existing as a platform needs to define an nvmem cell on the
athk9 device for this code to be used at all.

Alban

[toc] | [next] | [standalone]


#1608632 — Re: [PATCH 3/7] ath9k: Add support for reading the EEPROM data using the nvmem API

FromChristian Lamparter <chunkeey@googlemail.com>
Date2017-03-24 17:30 +0100
SubjectRe: [PATCH 3/7] ath9k: Add support for reading the EEPROM data using the nvmem API
Message-ID<toAga-4c4-13@gated-at.bofh.it>
In reply to#1607565
On Thursday, March 23, 2017 3:43:28 PM CET Alban wrote:
> On Tue, 14 Mar 2017 00:53:55 +0100
> Christian Lamparter <chunkeey@googlemail.com> wrote:
> 
> > On Monday, March 13, 2017 10:05:11 PM CET Alban wrote:
> > > Currently SoC platforms use a firmware request to get the EEPROM data.
> > > This is mostly a hack and rely on using a user-helper scripts which is
> > > deprecated. A nicer alternative is to use the nvmem API which was
> > > designed for this kind of task.
> > > 
> > > Furthermore we let CONFIG_ATH9K_AHB select CONFIG_NVMEM as such
> > > devices will generally use this method for loading the EEPROM data.
> > > 
> > > Signed-off-by: Alban <albeu@free.fr>
> > > ---
> > > @@ -654,6 +656,25 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc,
> > >  	if (ret)
> > >  		return ret;
> > >  
> > > +	/* If the EEPROM hasn't been retrieved via firmware request
> > > +	 * use the nvmem API insted.
> > > +	 */
> > > +	if (!ah->eeprom_blob) {
> > > +		struct nvmem_cell *eeprom_cell;
> > > +
> > > +		eeprom_cell = nvmem_cell_get(ah->dev, "eeprom");
> > > +		if (!IS_ERR(eeprom_cell)) {
> > > +			ah->eeprom_data = nvmem_cell_read(
> > > +				eeprom_cell, &ah->eeprom_size);
> > > +			nvmem_cell_put(eeprom_cell);
> > > +
> > > +			if (IS_ERR(ah->eeprom_data)) {
> > > +				dev_err(ah->dev, "failed to read eeprom");
> > > +				return PTR_ERR(ah->eeprom_data);
> > > +			}
> > > +		}
> > > +	}
> > > +
> > >  	if (ath9k_led_active_high != -1)
> > >  		ah->config.led_active_high = ath9k_led_active_high == 1;
> > >    
> > Are you sure this works with AR93XX SoCs that have the calibration data
> > in the OTP?
> 
> I only tested this on an ar9132 platform, so it might well be that a
> few things are missing for the newer SoC. However this shouldn't break
> anything existing as a platform needs to define an nvmem cell on the
> athk9 device for this code to be used a all.

Yes, I looked at it.
+		eeprom_cell = nvmem_cell_get(ah->dev, "eeprom");
+		if (!IS_ERR(eeprom_cell)) {
+			...
+		}
So if there's a error with the "eeprom" nvmem property,
(i.e.: it's not present) the driver should works as before.

Thanks,
Christian

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web