Linux wireless drivers development
 help / color / mirror / Atom feed
* RE: [PATCH V2] vlan priority handling in WMM
From: voncken @ 2013-07-08 10:39 UTC (permalink / raw)
  To: 'Johannes Berg'; +Cc: linux-wireless
In-Reply-To: <1373273460.8312.3.camel@jlt4.sipsolutions.net>


> > The vlan Tag contain three bit for priority. The value 0 indicate no 
> > priority (on this case the VLAN tag contain only VID). The vlan_tci 
> > field is set to zero if the frame do not contain the vlan tag. So if 
> > we have not a vlan tag or no priority in VLAN tag the priority value 
> > is always 0.

> Yes but don't we know that the vlan_tci field is valid?

> I don't think you're correct in that 0 means "no priority present", it actually means "best effort" as far as I can tell. Ignoring the VLAN tag when the field is 0 would mean we could use a higher priority from the contents of the frame, which would not be desired?

I can add a test with the macro vlan_tx_tag_present() to verify if the vlan_tci field is valid. 
I test the value 0 to skip the VLAN priority and use the dscp priority in this case. The priority 0 in VLAN tag is often use to turn off the QOS, because not bit is allowed for it.
For me is it correct. Nevertheless, if you prefer, I can test only the vlan_tci validity and in this case always use the VLAN priority.

> > Sorry but I don't understand. The vlan_tci field it is a __u16 value 
> > (defined in include/linux/skbuff.h), the VLAN_PRIO_MASK is set to
> > 0xE000 and VLAN_PRIO_SHIFT is set to 13 (defined in 
> > include/linux/if_vlan.h), the vlan_priority is an unsigned char. For 
> > me the vlan_priority contain a 3-bit value (0xE000 >>13 = 0x0003), why
> > 2 ?

> Umm? No? Think again about what hweight(0x0003) is.

Sorry I made a mistake  0xE000 >>13 = 0x0007 and not 0x0003, and 7 is a 3 bits value.

Cedric




^ permalink raw reply

* Re: [PATCH v2 5/5] rt2x00: rt2800lib: add EEPROM map for the RT3593 chipset
From: Gertjan van Wingerde @ 2013-07-08 10:06 UTC (permalink / raw)
  To: Gabor Juhos
  Cc: John Linville, linux-wireless@vger.kernel.org, rt2x00 Users List
In-Reply-To: <1373275556-6482-6-git-send-email-juhosg@openwrt.org>

On Mon, Jul 8, 2013 at 11:25 AM, Gabor Juhos <juhosg@openwrt.org> wrote:
> Three-chain devices are using a different
> EEPROM layout than the rest of the chipsets.
> Add a new map which describes the new layout
> and use that for the RT3593 chipset.
>
> The index values has been computed from the
> EEPROM_EXT_* defines, which can be found in
> the 'include/chip/rt3593.h' file in the
> Ralink DPO_RT5572_LinuxSTA_2.6.0.1_20120629
> driver.
>
> Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
> Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>

Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>

> ---
> Changes since v1: ---
> ---
>  drivers/net/wireless/rt2x00/rt2800.h    |    6 ++++
>  drivers/net/wireless/rt2x00/rt2800lib.c |   48 ++++++++++++++++++++++++++++++-
>  2 files changed, 53 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h
> index bc5c695..9216834 100644
> --- a/drivers/net/wireless/rt2x00/rt2800.h
> +++ b/drivers/net/wireless/rt2x00/rt2800.h
> @@ -2244,6 +2244,12 @@ enum rt2800_eeprom_word {
>         EEPROM_TSSI_BOUND_A5,
>         EEPROM_TXPOWER_BYRATE,
>         EEPROM_BBP_START,
> +
> +       /* IDs for extended EEPROM format used by three-chain devices */
> +       EEPROM_EXT_LNA2,
> +       EEPROM_EXT_TXPOWER_BG3,
> +       EEPROM_EXT_TXPOWER_A3,
> +
>         /* New values must be added before this */
>         EEPROM_WORD_COUNT
>  };
> diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
> index 41a34de4a..d325ca2 100644
> --- a/drivers/net/wireless/rt2x00/rt2800lib.c
> +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
> @@ -261,6 +261,48 @@ static const unsigned int rt2800_eeprom_map[EEPROM_WORD_COUNT] = {
>         [EEPROM_BBP_START]              = 0x0078,
>  };
>
> +static const unsigned int rt2800_eeprom_map_ext[EEPROM_WORD_COUNT] = {
> +       [EEPROM_CHIP_ID]                = 0x0000,
> +       [EEPROM_VERSION]                = 0x0001,
> +       [EEPROM_MAC_ADDR_0]             = 0x0002,
> +       [EEPROM_MAC_ADDR_1]             = 0x0003,
> +       [EEPROM_MAC_ADDR_2]             = 0x0004,
> +       [EEPROM_NIC_CONF0]              = 0x001a,
> +       [EEPROM_NIC_CONF1]              = 0x001b,
> +       [EEPROM_NIC_CONF2]              = 0x001c,
> +       [EEPROM_EIRP_MAX_TX_POWER]      = 0x0020,
> +       [EEPROM_FREQ]                   = 0x0022,
> +       [EEPROM_LED_AG_CONF]            = 0x0023,
> +       [EEPROM_LED_ACT_CONF]           = 0x0024,
> +       [EEPROM_LED_POLARITY]           = 0x0025,
> +       [EEPROM_LNA]                    = 0x0026,
> +       [EEPROM_EXT_LNA2]               = 0x0027,
> +       [EEPROM_RSSI_BG]                = 0x0028,
> +       [EEPROM_TXPOWER_DELTA]          = 0x0028, /* Overlaps with RSSI_BG */
> +       [EEPROM_RSSI_BG2]               = 0x0029,
> +       [EEPROM_TXMIXER_GAIN_BG]        = 0x0029, /* Overlaps with RSSI_BG2 */
> +       [EEPROM_RSSI_A]                 = 0x002a,
> +       [EEPROM_RSSI_A2]                = 0x002b,
> +       [EEPROM_TXMIXER_GAIN_A]         = 0x002b, /* Overlaps with RSSI_A2 */
> +       [EEPROM_TXPOWER_BG1]            = 0x0030,
> +       [EEPROM_TXPOWER_BG2]            = 0x0037,
> +       [EEPROM_EXT_TXPOWER_BG3]        = 0x003e,
> +       [EEPROM_TSSI_BOUND_BG1]         = 0x0045,
> +       [EEPROM_TSSI_BOUND_BG2]         = 0x0046,
> +       [EEPROM_TSSI_BOUND_BG3]         = 0x0047,
> +       [EEPROM_TSSI_BOUND_BG4]         = 0x0048,
> +       [EEPROM_TSSI_BOUND_BG5]         = 0x0049,
> +       [EEPROM_TXPOWER_A1]             = 0x004b,
> +       [EEPROM_TXPOWER_A2]             = 0x0065,
> +       [EEPROM_EXT_TXPOWER_A3]         = 0x007f,
> +       [EEPROM_TSSI_BOUND_A1]          = 0x009a,
> +       [EEPROM_TSSI_BOUND_A2]          = 0x009b,
> +       [EEPROM_TSSI_BOUND_A3]          = 0x009c,
> +       [EEPROM_TSSI_BOUND_A4]          = 0x009d,
> +       [EEPROM_TSSI_BOUND_A5]          = 0x009e,
> +       [EEPROM_TXPOWER_BYRATE]         = 0x00a0,
> +};
> +
>  static unsigned int rt2800_eeprom_word_index(struct rt2x00_dev *rt2x00dev,
>                                              const enum rt2800_eeprom_word word)
>  {
> @@ -272,7 +314,11 @@ static unsigned int rt2800_eeprom_word_index(struct rt2x00_dev *rt2x00dev,
>                       wiphy_name(rt2x00dev->hw->wiphy), word))
>                 return 0;
>
> -       map = rt2800_eeprom_map;
> +       if (rt2x00_rt(rt2x00dev, RT3593))
> +               map = rt2800_eeprom_map_ext;
> +       else
> +               map = rt2800_eeprom_map;
> +
>         index = map[word];
>
>         /* Index 0 is valid only for EEPROM_CHIP_ID.
> --
> 1.7.10
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



--
---
Gertjan

^ permalink raw reply

* Re: [PATCH v2 4/5] rt2x00: rt2800lib: introduce rt2800_eeprom_word_index helper
From: Gertjan van Wingerde @ 2013-07-08 10:04 UTC (permalink / raw)
  To: Gabor Juhos
  Cc: John Linville, linux-wireless@vger.kernel.org, rt2x00 Users List
In-Reply-To: <1373275556-6482-5-git-send-email-juhosg@openwrt.org>

On Mon, Jul 8, 2013 at 11:25 AM, Gabor Juhos <juhosg@openwrt.org> wrote:
> Instead of assign the offset value to the
> enum directly use a new helper function to
> convert a rt2800_eeprom_word enum into an
> index of the rt2x00_dev->eeprom array.
>
> The patch does not change the existing
> behaviour, but makes it possible to add
> support for three-chain devices which are
> using a different EEPROM layout.
>
> Signed-off-by: Gabor Juhos <juhosg@openwrt.org>

Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>

> ---
> Changes since v1:
>   - use WARN_ONCE and remove the rt2x00_warn calls
> ---
>  drivers/net/wireless/rt2x00/rt2800.h    |   76 ++++++++++++++-------------
>  drivers/net/wireless/rt2x00/rt2800lib.c |   87 +++++++++++++++++++++++++++++--
>  2 files changed, 122 insertions(+), 41 deletions(-)
>
> diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h
> index 0647039..bc5c695 100644
> --- a/drivers/net/wireless/rt2x00/rt2800.h
> +++ b/drivers/net/wireless/rt2x00/rt2800.h
> @@ -2207,43 +2207,45 @@ struct mac_iveiv_entry {
>   */
>
>  enum rt2800_eeprom_word {
> -       EEPROM_CHIP_ID          = 0x0000,
> -       EEPROM_VERSION          = 0x0001,
> -       EEPROM_MAC_ADDR_0       = 0x0002,
> -       EEPROM_MAC_ADDR_1       = 0x0003,
> -       EEPROM_MAC_ADDR_2       = 0x0004,
> -       EEPROM_NIC_CONF0        = 0x001a,
> -       EEPROM_NIC_CONF1        = 0x001b,
> -       EEPROM_FREQ             = 0x001d,
> -       EEPROM_LED_AG_CONF      = 0x001e,
> -       EEPROM_LED_ACT_CONF     = 0x001f,
> -       EEPROM_LED_POLARITY     = 0x0020,
> -       EEPROM_NIC_CONF2        = 0x0021,
> -       EEPROM_LNA              = 0x0022,
> -       EEPROM_RSSI_BG          = 0x0023,
> -       EEPROM_RSSI_BG2         = 0x0024,
> -       EEPROM_TXMIXER_GAIN_BG  = 0x0024, /* overlaps with RSSI_BG2 */
> -       EEPROM_RSSI_A           = 0x0025,
> -       EEPROM_RSSI_A2          = 0x0026,
> -       EEPROM_TXMIXER_GAIN_A   = 0x0026, /* overlaps with RSSI_A2 */
> -       EEPROM_EIRP_MAX_TX_POWER = 0x0027,
> -       EEPROM_TXPOWER_DELTA    = 0x0028,
> -       EEPROM_TXPOWER_BG1      = 0x0029,
> -       EEPROM_TXPOWER_BG2      = 0x0030,
> -       EEPROM_TSSI_BOUND_BG1   = 0x0037,
> -       EEPROM_TSSI_BOUND_BG2   = 0x0038,
> -       EEPROM_TSSI_BOUND_BG3   = 0x0039,
> -       EEPROM_TSSI_BOUND_BG4   = 0x003a,
> -       EEPROM_TSSI_BOUND_BG5   = 0x003b,
> -       EEPROM_TXPOWER_A1       = 0x003c,
> -       EEPROM_TXPOWER_A2       = 0x0053,
> -       EEPROM_TSSI_BOUND_A1    = 0x006a,
> -       EEPROM_TSSI_BOUND_A2    = 0x006b,
> -       EEPROM_TSSI_BOUND_A3    = 0x006c,
> -       EEPROM_TSSI_BOUND_A4    = 0x006d,
> -       EEPROM_TSSI_BOUND_A5    = 0x006e,
> -       EEPROM_TXPOWER_BYRATE   = 0x006f,
> -       EEPROM_BBP_START        = 0x0078,
> +       EEPROM_CHIP_ID = 0,
> +       EEPROM_VERSION,
> +       EEPROM_MAC_ADDR_0,
> +       EEPROM_MAC_ADDR_1,
> +       EEPROM_MAC_ADDR_2,
> +       EEPROM_NIC_CONF0,
> +       EEPROM_NIC_CONF1,
> +       EEPROM_FREQ,
> +       EEPROM_LED_AG_CONF,
> +       EEPROM_LED_ACT_CONF,
> +       EEPROM_LED_POLARITY,
> +       EEPROM_NIC_CONF2,
> +       EEPROM_LNA,
> +       EEPROM_RSSI_BG,
> +       EEPROM_RSSI_BG2,
> +       EEPROM_TXMIXER_GAIN_BG,
> +       EEPROM_RSSI_A,
> +       EEPROM_RSSI_A2,
> +       EEPROM_TXMIXER_GAIN_A,
> +       EEPROM_EIRP_MAX_TX_POWER,
> +       EEPROM_TXPOWER_DELTA,
> +       EEPROM_TXPOWER_BG1,
> +       EEPROM_TXPOWER_BG2,
> +       EEPROM_TSSI_BOUND_BG1,
> +       EEPROM_TSSI_BOUND_BG2,
> +       EEPROM_TSSI_BOUND_BG3,
> +       EEPROM_TSSI_BOUND_BG4,
> +       EEPROM_TSSI_BOUND_BG5,
> +       EEPROM_TXPOWER_A1,
> +       EEPROM_TXPOWER_A2,
> +       EEPROM_TSSI_BOUND_A1,
> +       EEPROM_TSSI_BOUND_A2,
> +       EEPROM_TSSI_BOUND_A3,
> +       EEPROM_TSSI_BOUND_A4,
> +       EEPROM_TSSI_BOUND_A5,
> +       EEPROM_TXPOWER_BYRATE,
> +       EEPROM_BBP_START,
> +       /* New values must be added before this */
> +       EEPROM_WORD_COUNT
>  };
>
>  /*
> diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
> index b59772a..41a34de4a 100644
> --- a/drivers/net/wireless/rt2x00/rt2800lib.c
> +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
> @@ -221,22 +221,98 @@ static void rt2800_rf_write(struct rt2x00_dev *rt2x00dev,
>         mutex_unlock(&rt2x00dev->csr_mutex);
>  }
>
> +static const unsigned int rt2800_eeprom_map[EEPROM_WORD_COUNT] = {
> +       [EEPROM_CHIP_ID]                = 0x0000,
> +       [EEPROM_VERSION]                = 0x0001,
> +       [EEPROM_MAC_ADDR_0]             = 0x0002,
> +       [EEPROM_MAC_ADDR_1]             = 0x0003,
> +       [EEPROM_MAC_ADDR_2]             = 0x0004,
> +       [EEPROM_NIC_CONF0]              = 0x001a,
> +       [EEPROM_NIC_CONF1]              = 0x001b,
> +       [EEPROM_FREQ]                   = 0x001d,
> +       [EEPROM_LED_AG_CONF]            = 0x001e,
> +       [EEPROM_LED_ACT_CONF]           = 0x001f,
> +       [EEPROM_LED_POLARITY]           = 0x0020,
> +       [EEPROM_NIC_CONF2]              = 0x0021,
> +       [EEPROM_LNA]                    = 0x0022,
> +       [EEPROM_RSSI_BG]                = 0x0023,
> +       [EEPROM_RSSI_BG2]               = 0x0024,
> +       [EEPROM_TXMIXER_GAIN_BG]        = 0x0024, /* overlaps with RSSI_BG2 */
> +       [EEPROM_RSSI_A]                 = 0x0025,
> +       [EEPROM_RSSI_A2]                = 0x0026,
> +       [EEPROM_TXMIXER_GAIN_A]         = 0x0026, /* overlaps with RSSI_A2 */
> +       [EEPROM_EIRP_MAX_TX_POWER]      = 0x0027,
> +       [EEPROM_TXPOWER_DELTA]          = 0x0028,
> +       [EEPROM_TXPOWER_BG1]            = 0x0029,
> +       [EEPROM_TXPOWER_BG2]            = 0x0030,
> +       [EEPROM_TSSI_BOUND_BG1]         = 0x0037,
> +       [EEPROM_TSSI_BOUND_BG2]         = 0x0038,
> +       [EEPROM_TSSI_BOUND_BG3]         = 0x0039,
> +       [EEPROM_TSSI_BOUND_BG4]         = 0x003a,
> +       [EEPROM_TSSI_BOUND_BG5]         = 0x003b,
> +       [EEPROM_TXPOWER_A1]             = 0x003c,
> +       [EEPROM_TXPOWER_A2]             = 0x0053,
> +       [EEPROM_TSSI_BOUND_A1]          = 0x006a,
> +       [EEPROM_TSSI_BOUND_A2]          = 0x006b,
> +       [EEPROM_TSSI_BOUND_A3]          = 0x006c,
> +       [EEPROM_TSSI_BOUND_A4]          = 0x006d,
> +       [EEPROM_TSSI_BOUND_A5]          = 0x006e,
> +       [EEPROM_TXPOWER_BYRATE]         = 0x006f,
> +       [EEPROM_BBP_START]              = 0x0078,
> +};
> +
> +static unsigned int rt2800_eeprom_word_index(struct rt2x00_dev *rt2x00dev,
> +                                            const enum rt2800_eeprom_word word)
> +{
> +       const unsigned int *map;
> +       unsigned int index;
> +
> +       if (WARN_ONCE(word >= EEPROM_WORD_COUNT,
> +                     "%s: invalid EEPROM word %d\n",
> +                     wiphy_name(rt2x00dev->hw->wiphy), word))
> +               return 0;
> +
> +       map = rt2800_eeprom_map;
> +       index = map[word];
> +
> +       /* Index 0 is valid only for EEPROM_CHIP_ID.
> +        * Otherwise it means that the offset of the
> +        * given word is not initialized in the map,
> +        * or that the field is not usable on the
> +        * actual chipset.
> +        */
> +       WARN_ONCE(word != EEPROM_CHIP_ID && index == 0,
> +                 "%s: invalid access of EEPROM word %d\n",
> +                 wiphy_name(rt2x00dev->hw->wiphy), word);
> +
> +       return index;
> +}
> +
>  static void *rt2800_eeprom_addr(struct rt2x00_dev *rt2x00dev,
>                                 const enum rt2800_eeprom_word word)
>  {
> -       return rt2x00_eeprom_addr(rt2x00dev, word);
> +       unsigned int index;
> +
> +       index = rt2800_eeprom_word_index(rt2x00dev, word);
> +       return rt2x00_eeprom_addr(rt2x00dev, index);
>  }
>
>  static void rt2800_eeprom_read(struct rt2x00_dev *rt2x00dev,
>                                const enum rt2800_eeprom_word word, u16 *data)
>  {
> -       rt2x00_eeprom_read(rt2x00dev, word, data);
> +       unsigned int index;
> +
> +       index = rt2800_eeprom_word_index(rt2x00dev, word);
> +       rt2x00_eeprom_read(rt2x00dev, index, data);
>  }
>
>  static void rt2800_eeprom_write(struct rt2x00_dev *rt2x00dev,
>                                 const enum rt2800_eeprom_word word, u16 data)
>  {
> -       rt2x00_eeprom_write(rt2x00dev, word, data);
> +       unsigned int index;
> +
> +       index = rt2800_eeprom_word_index(rt2x00dev, word);
> +       rt2x00_eeprom_write(rt2x00dev, index, data);
>  }
>
>  static void rt2800_eeprom_read_from_array(struct rt2x00_dev *rt2x00dev,
> @@ -244,7 +320,10 @@ static void rt2800_eeprom_read_from_array(struct rt2x00_dev *rt2x00dev,
>                                           unsigned int offset,
>                                           u16 *data)
>  {
> -       rt2x00_eeprom_read(rt2x00dev, array + offset, data);
> +       unsigned int index;
> +
> +       index = rt2800_eeprom_word_index(rt2x00dev, array);
> +       rt2x00_eeprom_read(rt2x00dev, index + offset, data);
>  }
>
>  static int rt2800_enable_wlan_rt3290(struct rt2x00_dev *rt2x00dev)
> --
> 1.7.10
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



--
---
Gertjan

^ permalink raw reply

* Re: [PATCH 3/3] [RFC] cfg80211: Enable GO operation on additional channels
From: Jouni Malinen @ 2013-07-08 10:04 UTC (permalink / raw)
  To: Ilan Peer; +Cc: linux-wireless, mcgrof, David Spinadel
In-Reply-To: <1372768095-26053-4-git-send-email-ilan.peer@intel.com>

On Tue, Jul 02, 2013 at 03:28:15PM +0300, Ilan Peer wrote:
> Allow GO operation on a channel marked with
> IEEE80211_CHAN_INDOOR_ONLY or IEEE80211_CHAN_GO_CONCURRENT
> iff there is an active station interface that is associated to
> an AP operating on this channel.
> 
> Note that this is a permissive approach to the FCC definitions,
> that require a clear assessment that either the platform device
> is an indoor device, or the device operating the AP is an indoor
> device, i.e., AC powered.
> It is assumed that these restrictions are enforced by user space.

The introduction in 0/3 mentioned DFS, but I did not see it being
addressed in any of the actual changes. Is this only for indoors vs.
outdoors?

> Furthermore, it is assumed, that if the conditions that allowed for
> the operation of the GO on such a channel change, it is the
> responsibility of user space to evacuate the GO from the channel.

Do you have plans or changes to address this? I'd assume wpa_supplicant
could stop the group on channel list changes, but I don't think it does
that currently.

-- 
Jouni Malinen                                            PGP id EFC895FA

^ permalink raw reply

* Re: [PATCH v2 3/5] rt2x00: rt2800lib: introduce rt2800_eeprom_read_from_array helper
From: Gertjan van Wingerde @ 2013-07-08 10:02 UTC (permalink / raw)
  To: Gabor Juhos
  Cc: John Linville, linux-wireless@vger.kernel.org, rt2x00 Users List
In-Reply-To: <1373275556-6482-4-git-send-email-juhosg@openwrt.org>

On Mon, Jul 8, 2013 at 11:25 AM, Gabor Juhos <juhosg@openwrt.org> wrote:
> Add a new helper function and use that for reading
> single elements of various arrays in the EEPROM.
>
> The patch does not change the current behaviour,
> but it allows to use sequential values for the
> rt2800_eeprom_word enums. The conversion will be
> implemented in a subsequent change.
>
> Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
> Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>

Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>

> ---
> Changes since v1: ---
> ---
>  drivers/net/wireless/rt2x00/rt2800lib.c |   23 ++++++++++++++++-------
>  1 file changed, 16 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
> index 522f0b1..b59772a 100644
> --- a/drivers/net/wireless/rt2x00/rt2800lib.c
> +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
> @@ -239,6 +239,14 @@ static void rt2800_eeprom_write(struct rt2x00_dev *rt2x00dev,
>         rt2x00_eeprom_write(rt2x00dev, word, data);
>  }
>
> +static void rt2800_eeprom_read_from_array(struct rt2x00_dev *rt2x00dev,
> +                                         const enum rt2800_eeprom_word array,
> +                                         unsigned int offset,
> +                                         u16 *data)
> +{
> +       rt2x00_eeprom_read(rt2x00dev, array + offset, data);
> +}
> +
>  static int rt2800_enable_wlan_rt3290(struct rt2x00_dev *rt2x00dev)
>  {
>         u32 reg;
> @@ -2995,8 +3003,8 @@ static u8 rt2800_compensate_txpower(struct rt2x00_dev *rt2x00dev, int is_rate_b,
>                  * .11b data rate need add additional 4dbm
>                  * when calculating eirp txpower.
>                  */
> -               rt2800_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + 1,
> -                                  &eeprom);
> +               rt2800_eeprom_read_from_array(rt2x00dev, EEPROM_TXPOWER_BYRATE,
> +                                             1, &eeprom);
>                 criterion = rt2x00_get_field16(eeprom,
>                                                EEPROM_TXPOWER_BYRATE_RATE0);
>
> @@ -3101,8 +3109,8 @@ static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev,
>                 rt2800_register_read(rt2x00dev, offset, &reg);
>
>                 /* read the next four txpower values */
> -               rt2800_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + i,
> -                                  &eeprom);
> +               rt2800_eeprom_read_from_array(rt2x00dev, EEPROM_TXPOWER_BYRATE,
> +                                             i, &eeprom);
>
>                 is_rate_b = i ? 0 : 1;
>                 /*
> @@ -3150,8 +3158,8 @@ static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev,
>                 rt2x00_set_field32(&reg, TX_PWR_CFG_RATE3, txpower);
>
>                 /* read the next four txpower values */
> -               rt2800_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + i + 1,
> -                                  &eeprom);
> +               rt2800_eeprom_read_from_array(rt2x00dev, EEPROM_TXPOWER_BYRATE,
> +                                             i + 1, &eeprom);
>
>                 is_rate_b = 0;
>                 /*
> @@ -4579,7 +4587,8 @@ static void rt2800_init_bbp(struct rt2x00_dev *rt2x00dev)
>         }
>
>         for (i = 0; i < EEPROM_BBP_SIZE; i++) {
> -               rt2800_eeprom_read(rt2x00dev, EEPROM_BBP_START + i, &eeprom);
> +               rt2800_eeprom_read_from_array(rt2x00dev, EEPROM_BBP_START, i,
> +                                             &eeprom);
>
>                 if (eeprom != 0xffff && eeprom != 0x0000) {
>                         reg_id = rt2x00_get_field16(eeprom, EEPROM_BBP_REG_ID);
> --
> 1.7.10
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



--
---
Gertjan

^ permalink raw reply

* Re: [PATCH v2 2/5] rt2x00: rt2800lib: introduce local EEPROM access functions
From: Gertjan van Wingerde @ 2013-07-08 10:00 UTC (permalink / raw)
  To: Gabor Juhos
  Cc: John Linville, linux-wireless@vger.kernel.org, rt2x00 Users List
In-Reply-To: <1373275556-6482-3-git-send-email-juhosg@openwrt.org>

On Mon, Jul 8, 2013 at 11:25 AM, Gabor Juhos <juhosg@openwrt.org> wrote:
> The patch adds rt2800 specific functions for
> EEPROM data access and changes the code to use
> these instead of the generic rt2x00_eeprom_*
> variants.
>
> To avoid functional changes, the new functions
> are wrappers around the corresponding generic
> rt2x00_eeprom_* routines for now. Functional
> changes will be implemented in additional patches.
>
> Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
> Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>

Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>

> ---
> Changes since v1: ---
> ---
>  drivers/net/wireless/rt2x00/rt2800lib.c |  165 ++++++++++++++++++-------------
>  1 file changed, 95 insertions(+), 70 deletions(-)
>
> diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
> index 1f80ea5..522f0b1 100644
> --- a/drivers/net/wireless/rt2x00/rt2800lib.c
> +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
> @@ -221,6 +221,24 @@ static void rt2800_rf_write(struct rt2x00_dev *rt2x00dev,
>         mutex_unlock(&rt2x00dev->csr_mutex);
>  }
>
> +static void *rt2800_eeprom_addr(struct rt2x00_dev *rt2x00dev,
> +                               const enum rt2800_eeprom_word word)
> +{
> +       return rt2x00_eeprom_addr(rt2x00dev, word);
> +}
> +
> +static void rt2800_eeprom_read(struct rt2x00_dev *rt2x00dev,
> +                              const enum rt2800_eeprom_word word, u16 *data)
> +{
> +       rt2x00_eeprom_read(rt2x00dev, word, data);
> +}
> +
> +static void rt2800_eeprom_write(struct rt2x00_dev *rt2x00dev,
> +                               const enum rt2800_eeprom_word word, u16 data)
> +{
> +       rt2x00_eeprom_write(rt2x00dev, word, data);
> +}
> +
>  static int rt2800_enable_wlan_rt3290(struct rt2x00_dev *rt2x00dev)
>  {
>         u32 reg;
> @@ -609,16 +627,16 @@ static int rt2800_agc_to_rssi(struct rt2x00_dev *rt2x00dev, u32 rxwi_w2)
>         u8 offset2;
>
>         if (rt2x00dev->curr_band == IEEE80211_BAND_2GHZ) {
> -               rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG, &eeprom);
> +               rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_BG, &eeprom);
>                 offset0 = rt2x00_get_field16(eeprom, EEPROM_RSSI_BG_OFFSET0);
>                 offset1 = rt2x00_get_field16(eeprom, EEPROM_RSSI_BG_OFFSET1);
> -               rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &eeprom);
> +               rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &eeprom);
>                 offset2 = rt2x00_get_field16(eeprom, EEPROM_RSSI_BG2_OFFSET2);
>         } else {
> -               rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A, &eeprom);
> +               rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_A, &eeprom);
>                 offset0 = rt2x00_get_field16(eeprom, EEPROM_RSSI_A_OFFSET0);
>                 offset1 = rt2x00_get_field16(eeprom, EEPROM_RSSI_A_OFFSET1);
> -               rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &eeprom);
> +               rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &eeprom);
>                 offset2 = rt2x00_get_field16(eeprom, EEPROM_RSSI_A2_OFFSET2);
>         }
>
> @@ -890,6 +908,9 @@ const struct rt2x00debug rt2800_rt2x00debug = {
>                 .word_count     = CSR_REG_SIZE / sizeof(u32),
>         },
>         .eeprom = {
> +               /* NOTE: The local EEPROM access functions can't
> +                * be used here, use the generic versions instead.
> +                */
>                 .read           = rt2x00_eeprom_read,
>                 .write          = rt2x00_eeprom_write,
>                 .word_base      = EEPROM_BASE,
> @@ -1547,7 +1568,7 @@ static void rt2800_config_3572bt_ant(struct rt2x00_dev *rt2x00dev)
>         led_r_mode = rt2x00_get_field32(reg, LED_CFG_LED_POLAR) ? 0 : 3;
>         if (led_g_mode != rt2x00_get_field32(reg, LED_CFG_G_LED_MODE) ||
>             led_r_mode != rt2x00_get_field32(reg, LED_CFG_R_LED_MODE)) {
> -               rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &eeprom);
> +               rt2800_eeprom_read(rt2x00dev, EEPROM_FREQ, &eeprom);
>                 led_ctrl = rt2x00_get_field16(eeprom, EEPROM_FREQ_LED_MODE);
>                 if (led_ctrl == 0 || led_ctrl > 0x40) {
>                         rt2x00_set_field32(&reg, LED_CFG_G_LED_MODE, led_g_mode);
> @@ -1622,7 +1643,7 @@ void rt2800_config_ant(struct rt2x00_dev *rt2x00dev, struct antenna_setup *ant)
>                     rt2x00_rt(rt2x00dev, RT3090) ||
>                     rt2x00_rt(rt2x00dev, RT3352) ||
>                     rt2x00_rt(rt2x00dev, RT3390)) {
> -                       rt2x00_eeprom_read(rt2x00dev,
> +                       rt2800_eeprom_read(rt2x00dev,
>                                            EEPROM_NIC_CONF1, &eeprom);
>                         if (rt2x00_get_field16(eeprom,
>                                                 EEPROM_NIC_CONF1_ANT_DIVERSITY))
> @@ -1659,16 +1680,16 @@ static void rt2800_config_lna_gain(struct rt2x00_dev *rt2x00dev,
>         short lna_gain;
>
>         if (libconf->rf.channel <= 14) {
> -               rt2x00_eeprom_read(rt2x00dev, EEPROM_LNA, &eeprom);
> +               rt2800_eeprom_read(rt2x00dev, EEPROM_LNA, &eeprom);
>                 lna_gain = rt2x00_get_field16(eeprom, EEPROM_LNA_BG);
>         } else if (libconf->rf.channel <= 64) {
> -               rt2x00_eeprom_read(rt2x00dev, EEPROM_LNA, &eeprom);
> +               rt2800_eeprom_read(rt2x00dev, EEPROM_LNA, &eeprom);
>                 lna_gain = rt2x00_get_field16(eeprom, EEPROM_LNA_A0);
>         } else if (libconf->rf.channel <= 128) {
> -               rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &eeprom);
> +               rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &eeprom);
>                 lna_gain = rt2x00_get_field16(eeprom, EEPROM_RSSI_BG2_LNA_A1);
>         } else {
> -               rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &eeprom);
> +               rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &eeprom);
>                 lna_gain = rt2x00_get_field16(eeprom, EEPROM_RSSI_A2_LNA_A2);
>         }
>
> @@ -2798,62 +2819,62 @@ static int rt2800_get_gain_calibration_delta(struct rt2x00_dev *rt2x00dev)
>          * Example TSSI bounds  0xF0 0xD0 0xB5 0xA0 0x88 0x45 0x25 0x15 0x00
>          */
>         if (rt2x00dev->curr_band == IEEE80211_BAND_2GHZ) {
> -               rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG1, &eeprom);
> +               rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG1, &eeprom);
>                 tssi_bounds[0] = rt2x00_get_field16(eeprom,
>                                         EEPROM_TSSI_BOUND_BG1_MINUS4);
>                 tssi_bounds[1] = rt2x00_get_field16(eeprom,
>                                         EEPROM_TSSI_BOUND_BG1_MINUS3);
>
> -               rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG2, &eeprom);
> +               rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG2, &eeprom);
>                 tssi_bounds[2] = rt2x00_get_field16(eeprom,
>                                         EEPROM_TSSI_BOUND_BG2_MINUS2);
>                 tssi_bounds[3] = rt2x00_get_field16(eeprom,
>                                         EEPROM_TSSI_BOUND_BG2_MINUS1);
>
> -               rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG3, &eeprom);
> +               rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG3, &eeprom);
>                 tssi_bounds[4] = rt2x00_get_field16(eeprom,
>                                         EEPROM_TSSI_BOUND_BG3_REF);
>                 tssi_bounds[5] = rt2x00_get_field16(eeprom,
>                                         EEPROM_TSSI_BOUND_BG3_PLUS1);
>
> -               rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG4, &eeprom);
> +               rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG4, &eeprom);
>                 tssi_bounds[6] = rt2x00_get_field16(eeprom,
>                                         EEPROM_TSSI_BOUND_BG4_PLUS2);
>                 tssi_bounds[7] = rt2x00_get_field16(eeprom,
>                                         EEPROM_TSSI_BOUND_BG4_PLUS3);
>
> -               rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG5, &eeprom);
> +               rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG5, &eeprom);
>                 tssi_bounds[8] = rt2x00_get_field16(eeprom,
>                                         EEPROM_TSSI_BOUND_BG5_PLUS4);
>
>                 step = rt2x00_get_field16(eeprom,
>                                           EEPROM_TSSI_BOUND_BG5_AGC_STEP);
>         } else {
> -               rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A1, &eeprom);
> +               rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A1, &eeprom);
>                 tssi_bounds[0] = rt2x00_get_field16(eeprom,
>                                         EEPROM_TSSI_BOUND_A1_MINUS4);
>                 tssi_bounds[1] = rt2x00_get_field16(eeprom,
>                                         EEPROM_TSSI_BOUND_A1_MINUS3);
>
> -               rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A2, &eeprom);
> +               rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A2, &eeprom);
>                 tssi_bounds[2] = rt2x00_get_field16(eeprom,
>                                         EEPROM_TSSI_BOUND_A2_MINUS2);
>                 tssi_bounds[3] = rt2x00_get_field16(eeprom,
>                                         EEPROM_TSSI_BOUND_A2_MINUS1);
>
> -               rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A3, &eeprom);
> +               rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A3, &eeprom);
>                 tssi_bounds[4] = rt2x00_get_field16(eeprom,
>                                         EEPROM_TSSI_BOUND_A3_REF);
>                 tssi_bounds[5] = rt2x00_get_field16(eeprom,
>                                         EEPROM_TSSI_BOUND_A3_PLUS1);
>
> -               rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A4, &eeprom);
> +               rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A4, &eeprom);
>                 tssi_bounds[6] = rt2x00_get_field16(eeprom,
>                                         EEPROM_TSSI_BOUND_A4_PLUS2);
>                 tssi_bounds[7] = rt2x00_get_field16(eeprom,
>                                         EEPROM_TSSI_BOUND_A4_PLUS3);
>
> -               rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A5, &eeprom);
> +               rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A5, &eeprom);
>                 tssi_bounds[8] = rt2x00_get_field16(eeprom,
>                                         EEPROM_TSSI_BOUND_A5_PLUS4);
>
> @@ -2899,7 +2920,7 @@ static int rt2800_get_txpower_bw_comp(struct rt2x00_dev *rt2x00dev,
>         u8 comp_type;
>         int comp_value = 0;
>
> -       rt2x00_eeprom_read(rt2x00dev, EEPROM_TXPOWER_DELTA, &eeprom);
> +       rt2800_eeprom_read(rt2x00dev, EEPROM_TXPOWER_DELTA, &eeprom);
>
>         /*
>          * HT40 compensation not required.
> @@ -2974,12 +2995,12 @@ static u8 rt2800_compensate_txpower(struct rt2x00_dev *rt2x00dev, int is_rate_b,
>                  * .11b data rate need add additional 4dbm
>                  * when calculating eirp txpower.
>                  */
> -               rt2x00_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + 1,
> +               rt2800_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + 1,
>                                    &eeprom);
>                 criterion = rt2x00_get_field16(eeprom,
>                                                EEPROM_TXPOWER_BYRATE_RATE0);
>
> -               rt2x00_eeprom_read(rt2x00dev, EEPROM_EIRP_MAX_TX_POWER,
> +               rt2800_eeprom_read(rt2x00dev, EEPROM_EIRP_MAX_TX_POWER,
>                                    &eeprom);
>
>                 if (band == IEEE80211_BAND_2GHZ)
> @@ -3080,7 +3101,7 @@ static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev,
>                 rt2800_register_read(rt2x00dev, offset, &reg);
>
>                 /* read the next four txpower values */
> -               rt2x00_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + i,
> +               rt2800_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + i,
>                                    &eeprom);
>
>                 is_rate_b = i ? 0 : 1;
> @@ -3129,7 +3150,7 @@ static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev,
>                 rt2x00_set_field32(&reg, TX_PWR_CFG_RATE3, txpower);
>
>                 /* read the next four txpower values */
> -               rt2x00_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + i + 1,
> +               rt2800_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + i + 1,
>                                    &eeprom);
>
>                 is_rate_b = 0;
> @@ -3528,7 +3549,8 @@ static int rt2800_init_registers(struct rt2x00_dev *rt2x00dev)
>                 if (rt2x00_rt_rev_lt(rt2x00dev, RT3071, REV_RT3071E) ||
>                     rt2x00_rt_rev_lt(rt2x00dev, RT3090, REV_RT3090E) ||
>                     rt2x00_rt_rev_lt(rt2x00dev, RT3390, REV_RT3390E)) {
> -                       rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
> +                       rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1,
> +                                          &eeprom);
>                         if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_DAC_TEST))
>                                 rt2800_register_write(rt2x00dev, TX_SW_CFG2,
>                                                       0x0000002c);
> @@ -3989,7 +4011,7 @@ static void rt2800_disable_unused_dac_adc(struct rt2x00_dev *rt2x00dev)
>         u8 value;
>
>         rt2800_bbp_read(rt2x00dev, 138, &value);
> -       rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
> +       rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
>         if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_TXPATH) == 1)
>                 value |= 0x20;
>         if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH) == 1)
> @@ -4402,7 +4424,7 @@ static void rt2800_init_bbp_53xx(struct rt2x00_dev *rt2x00dev)
>
>         rt2800_disable_unused_dac_adc(rt2x00dev);
>
> -       rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
> +       rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
>         div_mode = rt2x00_get_field16(eeprom,
>                                       EEPROM_NIC_CONF1_ANT_DIVERSITY);
>         ant = (div_mode == 3) ? 1 : 0;
> @@ -4488,7 +4510,7 @@ static void rt2800_init_bbp_5592(struct rt2x00_dev *rt2x00dev)
>
>         rt2800_bbp4_mac_if_ctrl(rt2x00dev);
>
> -       rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
> +       rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
>         div_mode = rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_ANT_DIVERSITY);
>         ant = (div_mode == 3) ? 1 : 0;
>         rt2800_bbp_read(rt2x00dev, 152, &value);
> @@ -4557,7 +4579,7 @@ static void rt2800_init_bbp(struct rt2x00_dev *rt2x00dev)
>         }
>
>         for (i = 0; i < EEPROM_BBP_SIZE; i++) {
> -               rt2x00_eeprom_read(rt2x00dev, EEPROM_BBP_START + i, &eeprom);
> +               rt2800_eeprom_read(rt2x00dev, EEPROM_BBP_START + i, &eeprom);
>
>                 if (eeprom != 0xffff && eeprom != 0x0000) {
>                         reg_id = rt2x00_get_field16(eeprom, EEPROM_BBP_REG_ID);
> @@ -4728,7 +4750,7 @@ static void rt2800_normal_mode_setup_3xxx(struct rt2x00_dev *rt2x00dev)
>         if (rt2x00_rt(rt2x00dev, RT3090)) {
>                 /*  Turn off unused DAC1 and ADC1 to reduce power consumption */
>                 rt2800_bbp_read(rt2x00dev, 138, &bbp);
> -               rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
> +               rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
>                 if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH) == 1)
>                         rt2x00_set_field8(&bbp, BBP138_RX_ADC1, 0);
>                 if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_TXPATH) == 1)
> @@ -4778,7 +4800,7 @@ static void rt2800_normal_mode_setup_5xxx(struct rt2x00_dev *rt2x00dev)
>
>         /*  Turn off unused DAC1 and ADC1 to reduce power consumption */
>         rt2800_bbp_read(rt2x00dev, 138, &reg);
> -       rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
> +       rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
>         if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH) == 1)
>                 rt2x00_set_field8(&reg, BBP138_RX_ADC1, 0);
>         if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_TXPATH) == 1)
> @@ -4884,7 +4906,8 @@ static void rt2800_init_rfcsr_30xx(struct rt2x00_dev *rt2x00dev)
>                 rt2x00_set_field32(&reg, LDO_CFG0_BGSEL, 1);
>                 if (rt2x00_rt_rev_lt(rt2x00dev, RT3071, REV_RT3071E) ||
>                     rt2x00_rt_rev_lt(rt2x00dev, RT3090, REV_RT3090E)) {
> -                       rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
> +                       rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1,
> +                                          &eeprom);
>                         if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_DAC_TEST))
>                                 rt2x00_set_field32(&reg, LDO_CFG0_LDO_CORE_VLEVEL, 3);
>                         else
> @@ -5456,15 +5479,15 @@ int rt2800_enable_radio(struct rt2x00_dev *rt2x00dev)
>         /*
>          * Initialize LED control
>          */
> -       rt2x00_eeprom_read(rt2x00dev, EEPROM_LED_AG_CONF, &word);
> +       rt2800_eeprom_read(rt2x00dev, EEPROM_LED_AG_CONF, &word);
>         rt2800_mcu_request(rt2x00dev, MCU_LED_AG_CONF, 0xff,
>                            word & 0xff, (word >> 8) & 0xff);
>
> -       rt2x00_eeprom_read(rt2x00dev, EEPROM_LED_ACT_CONF, &word);
> +       rt2800_eeprom_read(rt2x00dev, EEPROM_LED_ACT_CONF, &word);
>         rt2800_mcu_request(rt2x00dev, MCU_LED_ACT_CONF, 0xff,
>                            word & 0xff, (word >> 8) & 0xff);
>
> -       rt2x00_eeprom_read(rt2x00dev, EEPROM_LED_POLARITY, &word);
> +       rt2800_eeprom_read(rt2x00dev, EEPROM_LED_POLARITY, &word);
>         rt2800_mcu_request(rt2x00dev, MCU_LED_LED_POLARITY, 0xff,
>                            word & 0xff, (word >> 8) & 0xff);
>
> @@ -5578,18 +5601,18 @@ static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
>         /*
>          * Start validation of the data that has been read.
>          */
> -       mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
> +       mac = rt2800_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
>         if (!is_valid_ether_addr(mac)) {
>                 eth_random_addr(mac);
>                 rt2x00_eeprom_dbg(rt2x00dev, "MAC: %pM\n", mac);
>         }
>
> -       rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &word);
> +       rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &word);
>         if (word == 0xffff) {
>                 rt2x00_set_field16(&word, EEPROM_NIC_CONF0_RXPATH, 2);
>                 rt2x00_set_field16(&word, EEPROM_NIC_CONF0_TXPATH, 1);
>                 rt2x00_set_field16(&word, EEPROM_NIC_CONF0_RF_TYPE, RF2820);
> -               rt2x00_eeprom_write(rt2x00dev, EEPROM_NIC_CONF0, word);
> +               rt2800_eeprom_write(rt2x00dev, EEPROM_NIC_CONF0, word);
>                 rt2x00_eeprom_dbg(rt2x00dev, "Antenna: 0x%04x\n", word);
>         } else if (rt2x00_rt(rt2x00dev, RT2860) ||
>                    rt2x00_rt(rt2x00dev, RT2872)) {
> @@ -5598,10 +5621,10 @@ static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
>                  */
>                 if (rt2x00_get_field16(word, EEPROM_NIC_CONF0_RXPATH) > 2)
>                         rt2x00_set_field16(&word, EEPROM_NIC_CONF0_RXPATH, 2);
> -               rt2x00_eeprom_write(rt2x00dev, EEPROM_NIC_CONF0, word);
> +               rt2800_eeprom_write(rt2x00dev, EEPROM_NIC_CONF0, word);
>         }
>
> -       rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &word);
> +       rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &word);
>         if (word == 0xffff) {
>                 rt2x00_set_field16(&word, EEPROM_NIC_CONF1_HW_RADIO, 0);
>                 rt2x00_set_field16(&word, EEPROM_NIC_CONF1_EXTERNAL_TX_ALC, 0);
> @@ -5618,24 +5641,24 @@ static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
>                 rt2x00_set_field16(&word, EEPROM_NIC_CONF1_INTERNAL_TX_ALC, 0);
>                 rt2x00_set_field16(&word, EEPROM_NIC_CONF1_BT_COEXIST, 0);
>                 rt2x00_set_field16(&word, EEPROM_NIC_CONF1_DAC_TEST, 0);
> -               rt2x00_eeprom_write(rt2x00dev, EEPROM_NIC_CONF1, word);
> +               rt2800_eeprom_write(rt2x00dev, EEPROM_NIC_CONF1, word);
>                 rt2x00_eeprom_dbg(rt2x00dev, "NIC: 0x%04x\n", word);
>         }
>
> -       rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &word);
> +       rt2800_eeprom_read(rt2x00dev, EEPROM_FREQ, &word);
>         if ((word & 0x00ff) == 0x00ff) {
>                 rt2x00_set_field16(&word, EEPROM_FREQ_OFFSET, 0);
> -               rt2x00_eeprom_write(rt2x00dev, EEPROM_FREQ, word);
> +               rt2800_eeprom_write(rt2x00dev, EEPROM_FREQ, word);
>                 rt2x00_eeprom_dbg(rt2x00dev, "Freq: 0x%04x\n", word);
>         }
>         if ((word & 0xff00) == 0xff00) {
>                 rt2x00_set_field16(&word, EEPROM_FREQ_LED_MODE,
>                                    LED_MODE_TXRX_ACTIVITY);
>                 rt2x00_set_field16(&word, EEPROM_FREQ_LED_POLARITY, 0);
> -               rt2x00_eeprom_write(rt2x00dev, EEPROM_FREQ, word);
> -               rt2x00_eeprom_write(rt2x00dev, EEPROM_LED_AG_CONF, 0x5555);
> -               rt2x00_eeprom_write(rt2x00dev, EEPROM_LED_ACT_CONF, 0x2221);
> -               rt2x00_eeprom_write(rt2x00dev, EEPROM_LED_POLARITY, 0xa9f8);
> +               rt2800_eeprom_write(rt2x00dev, EEPROM_FREQ, word);
> +               rt2800_eeprom_write(rt2x00dev, EEPROM_LED_AG_CONF, 0x5555);
> +               rt2800_eeprom_write(rt2x00dev, EEPROM_LED_ACT_CONF, 0x2221);
> +               rt2800_eeprom_write(rt2x00dev, EEPROM_LED_POLARITY, 0xa9f8);
>                 rt2x00_eeprom_dbg(rt2x00dev, "Led Mode: 0x%04x\n", word);
>         }
>
> @@ -5644,17 +5667,17 @@ static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
>          * lna0 as correct value. Note that EEPROM_LNA
>          * is never validated.
>          */
> -       rt2x00_eeprom_read(rt2x00dev, EEPROM_LNA, &word);
> +       rt2800_eeprom_read(rt2x00dev, EEPROM_LNA, &word);
>         default_lna_gain = rt2x00_get_field16(word, EEPROM_LNA_A0);
>
> -       rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG, &word);
> +       rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_BG, &word);
>         if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG_OFFSET0)) > 10)
>                 rt2x00_set_field16(&word, EEPROM_RSSI_BG_OFFSET0, 0);
>         if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG_OFFSET1)) > 10)
>                 rt2x00_set_field16(&word, EEPROM_RSSI_BG_OFFSET1, 0);
> -       rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_BG, word);
> +       rt2800_eeprom_write(rt2x00dev, EEPROM_RSSI_BG, word);
>
> -       rt2x00_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_BG, &word);
> +       rt2800_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_BG, &word);
>         if ((word & 0x00ff) != 0x00ff) {
>                 drv_data->txmixer_gain_24g =
>                         rt2x00_get_field16(word, EEPROM_TXMIXER_GAIN_BG_VAL);
> @@ -5662,16 +5685,16 @@ static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
>                 drv_data->txmixer_gain_24g = 0;
>         }
>
> -       rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &word);
> +       rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &word);
>         if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG2_OFFSET2)) > 10)
>                 rt2x00_set_field16(&word, EEPROM_RSSI_BG2_OFFSET2, 0);
>         if (rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0x00 ||
>             rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0xff)
>                 rt2x00_set_field16(&word, EEPROM_RSSI_BG2_LNA_A1,
>                                    default_lna_gain);
> -       rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_BG2, word);
> +       rt2800_eeprom_write(rt2x00dev, EEPROM_RSSI_BG2, word);
>
> -       rt2x00_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_A, &word);
> +       rt2800_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_A, &word);
>         if ((word & 0x00ff) != 0x00ff) {
>                 drv_data->txmixer_gain_5g =
>                         rt2x00_get_field16(word, EEPROM_TXMIXER_GAIN_A_VAL);
> @@ -5679,21 +5702,21 @@ static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
>                 drv_data->txmixer_gain_5g = 0;
>         }
>
> -       rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A, &word);
> +       rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_A, &word);
>         if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A_OFFSET0)) > 10)
>                 rt2x00_set_field16(&word, EEPROM_RSSI_A_OFFSET0, 0);
>         if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A_OFFSET1)) > 10)
>                 rt2x00_set_field16(&word, EEPROM_RSSI_A_OFFSET1, 0);
> -       rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_A, word);
> +       rt2800_eeprom_write(rt2x00dev, EEPROM_RSSI_A, word);
>
> -       rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &word);
> +       rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &word);
>         if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A2_OFFSET2)) > 10)
>                 rt2x00_set_field16(&word, EEPROM_RSSI_A2_OFFSET2, 0);
>         if (rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0x00 ||
>             rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0xff)
>                 rt2x00_set_field16(&word, EEPROM_RSSI_A2_LNA_A2,
>                                    default_lna_gain);
> -       rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_A2, word);
> +       rt2800_eeprom_write(rt2x00dev, EEPROM_RSSI_A2, word);
>
>         return 0;
>  }
> @@ -5707,7 +5730,7 @@ static int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
>         /*
>          * Read EEPROM word for configuration.
>          */
> -       rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
> +       rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
>
>         /*
>          * Identify RF chipset by EEPROM value
> @@ -5717,7 +5740,7 @@ static int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
>         if (rt2x00_rt(rt2x00dev, RT3290) ||
>             rt2x00_rt(rt2x00dev, RT5390) ||
>             rt2x00_rt(rt2x00dev, RT5392))
> -               rt2x00_eeprom_read(rt2x00dev, EEPROM_CHIP_ID, &rf);
> +               rt2800_eeprom_read(rt2x00dev, EEPROM_CHIP_ID, &rf);
>         else
>                 rf = rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RF_TYPE);
>
> @@ -5757,7 +5780,7 @@ static int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
>         rt2x00dev->default_ant.rx_chain_num =
>             rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH);
>
> -       rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
> +       rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
>
>         if (rt2x00_rt(rt2x00dev, RT3070) ||
>             rt2x00_rt(rt2x00dev, RT3090) ||
> @@ -5810,7 +5833,7 @@ static int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
>         /*
>          * Read frequency offset and RF programming sequence.
>          */
> -       rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &eeprom);
> +       rt2800_eeprom_read(rt2x00dev, EEPROM_FREQ, &eeprom);
>         rt2x00dev->freq_offset = rt2x00_get_field16(eeprom, EEPROM_FREQ_OFFSET);
>
>         /*
> @@ -5827,7 +5850,7 @@ static int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
>         /*
>          * Check if support EIRP tx power limit feature.
>          */
> -       rt2x00_eeprom_read(rt2x00dev, EEPROM_EIRP_MAX_TX_POWER, &eeprom);
> +       rt2800_eeprom_read(rt2x00dev, EEPROM_EIRP_MAX_TX_POWER, &eeprom);
>
>         if (rt2x00_get_field16(eeprom, EEPROM_EIRP_MAX_TX_POWER_2GHZ) <
>                                         EIRP_MAX_TX_POWER_LIMIT)
> @@ -6148,7 +6171,7 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
>
>         SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
>         SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
> -                               rt2x00_eeprom_addr(rt2x00dev,
> +                               rt2800_eeprom_addr(rt2x00dev,
>                                                    EEPROM_MAC_ADDR_0));
>
>         /*
> @@ -6164,7 +6187,7 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
>         rt2x00dev->hw->max_report_rates = 7;
>         rt2x00dev->hw->max_rate_tries = 1;
>
> -       rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
> +       rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
>
>         /*
>          * Initialize hw_mode information.
> @@ -6264,8 +6287,8 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
>
>         spec->channels_info = info;
>
> -       default_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG1);
> -       default_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG2);
> +       default_power1 = rt2800_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG1);
> +       default_power2 = rt2800_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG2);
>
>         for (i = 0; i < 14; i++) {
>                 info[i].default_power1 = default_power1[i];
> @@ -6273,8 +6296,10 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
>         }
>
>         if (spec->num_channels > 14) {
> -               default_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A1);
> -               default_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A2);
> +               default_power1 = rt2800_eeprom_addr(rt2x00dev,
> +                                                   EEPROM_TXPOWER_A1);
> +               default_power2 = rt2800_eeprom_addr(rt2x00dev,
> +                                                   EEPROM_TXPOWER_A2);
>
>                 for (i = 14; i < spec->num_channels; i++) {
>                         info[i].default_power1 = default_power1[i - 14];
> --
> 1.7.10
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



--
---
Gertjan

^ permalink raw reply

* Re: [PATCH v2 1/5] rt2x00: rt2800lib: introduce rt2800_eeprom_word enum
From: Gertjan van Wingerde @ 2013-07-08  9:59 UTC (permalink / raw)
  To: Gabor Juhos
  Cc: John Linville, linux-wireless@vger.kernel.org, rt2x00 Users List
In-Reply-To: <1373275556-6482-2-git-send-email-juhosg@openwrt.org>

On Mon, Jul 8, 2013 at 11:25 AM, Gabor Juhos <juhosg@openwrt.org> wrote:
> The patch converts the EEPROM_* word address defines
> into new enum values. The new enum type will be used
> by new functions which will be introduced in subsequent
> changes.
>
> The patch contains no functional changes.
>
> Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
> Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>

Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>

> ---
> Changes since v1: ---
> ---
>  drivers/net/wireless/rt2x00/rt2800.h |   79 +++++++++++++++++-----------------
>  1 file changed, 39 insertions(+), 40 deletions(-)
>
> diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h
> index d78c495..0647039 100644
> --- a/drivers/net/wireless/rt2x00/rt2800.h
> +++ b/drivers/net/wireless/rt2x00/rt2800.h
> @@ -2206,28 +2206,59 @@ struct mac_iveiv_entry {
>   * The wordsize of the EEPROM is 16 bits.
>   */
>
> -/*
> - * Chip ID
> - */
> -#define EEPROM_CHIP_ID                 0x0000
> +enum rt2800_eeprom_word {
> +       EEPROM_CHIP_ID          = 0x0000,
> +       EEPROM_VERSION          = 0x0001,
> +       EEPROM_MAC_ADDR_0       = 0x0002,
> +       EEPROM_MAC_ADDR_1       = 0x0003,
> +       EEPROM_MAC_ADDR_2       = 0x0004,
> +       EEPROM_NIC_CONF0        = 0x001a,
> +       EEPROM_NIC_CONF1        = 0x001b,
> +       EEPROM_FREQ             = 0x001d,
> +       EEPROM_LED_AG_CONF      = 0x001e,
> +       EEPROM_LED_ACT_CONF     = 0x001f,
> +       EEPROM_LED_POLARITY     = 0x0020,
> +       EEPROM_NIC_CONF2        = 0x0021,
> +       EEPROM_LNA              = 0x0022,
> +       EEPROM_RSSI_BG          = 0x0023,
> +       EEPROM_RSSI_BG2         = 0x0024,
> +       EEPROM_TXMIXER_GAIN_BG  = 0x0024, /* overlaps with RSSI_BG2 */
> +       EEPROM_RSSI_A           = 0x0025,
> +       EEPROM_RSSI_A2          = 0x0026,
> +       EEPROM_TXMIXER_GAIN_A   = 0x0026, /* overlaps with RSSI_A2 */
> +       EEPROM_EIRP_MAX_TX_POWER = 0x0027,
> +       EEPROM_TXPOWER_DELTA    = 0x0028,
> +       EEPROM_TXPOWER_BG1      = 0x0029,
> +       EEPROM_TXPOWER_BG2      = 0x0030,
> +       EEPROM_TSSI_BOUND_BG1   = 0x0037,
> +       EEPROM_TSSI_BOUND_BG2   = 0x0038,
> +       EEPROM_TSSI_BOUND_BG3   = 0x0039,
> +       EEPROM_TSSI_BOUND_BG4   = 0x003a,
> +       EEPROM_TSSI_BOUND_BG5   = 0x003b,
> +       EEPROM_TXPOWER_A1       = 0x003c,
> +       EEPROM_TXPOWER_A2       = 0x0053,
> +       EEPROM_TSSI_BOUND_A1    = 0x006a,
> +       EEPROM_TSSI_BOUND_A2    = 0x006b,
> +       EEPROM_TSSI_BOUND_A3    = 0x006c,
> +       EEPROM_TSSI_BOUND_A4    = 0x006d,
> +       EEPROM_TSSI_BOUND_A5    = 0x006e,
> +       EEPROM_TXPOWER_BYRATE   = 0x006f,
> +       EEPROM_BBP_START        = 0x0078,
> +};
>
>  /*
>   * EEPROM Version
>   */
> -#define EEPROM_VERSION                 0x0001
>  #define EEPROM_VERSION_FAE             FIELD16(0x00ff)
>  #define EEPROM_VERSION_VERSION         FIELD16(0xff00)
>
>  /*
>   * HW MAC address.
>   */
> -#define EEPROM_MAC_ADDR_0              0x0002
>  #define EEPROM_MAC_ADDR_BYTE0          FIELD16(0x00ff)
>  #define EEPROM_MAC_ADDR_BYTE1          FIELD16(0xff00)
> -#define EEPROM_MAC_ADDR_1              0x0003
>  #define EEPROM_MAC_ADDR_BYTE2          FIELD16(0x00ff)
>  #define EEPROM_MAC_ADDR_BYTE3          FIELD16(0xff00)
> -#define EEPROM_MAC_ADDR_2              0x0004
>  #define EEPROM_MAC_ADDR_BYTE4          FIELD16(0x00ff)
>  #define EEPROM_MAC_ADDR_BYTE5          FIELD16(0xff00)
>
> @@ -2237,7 +2268,6 @@ struct mac_iveiv_entry {
>   * TXPATH: 1: 1T, 2: 2T, 3: 3T
>   * RF_TYPE: RFIC type
>   */
> -#define        EEPROM_NIC_CONF0                0x001a
>  #define EEPROM_NIC_CONF0_RXPATH                FIELD16(0x000f)
>  #define EEPROM_NIC_CONF0_TXPATH                FIELD16(0x00f0)
>  #define EEPROM_NIC_CONF0_RF_TYPE               FIELD16(0x0f00)
> @@ -2261,7 +2291,6 @@ struct mac_iveiv_entry {
>   * BT_COEXIST: 0: disable, 1: enable
>   * DAC_TEST: 0: disable, 1: enable
>   */
> -#define        EEPROM_NIC_CONF1                0x001b
>  #define EEPROM_NIC_CONF1_HW_RADIO              FIELD16(0x0001)
>  #define EEPROM_NIC_CONF1_EXTERNAL_TX_ALC               FIELD16(0x0002)
>  #define EEPROM_NIC_CONF1_EXTERNAL_LNA_2G               FIELD16(0x0004)
> @@ -2281,7 +2310,6 @@ struct mac_iveiv_entry {
>  /*
>   * EEPROM frequency
>   */
> -#define        EEPROM_FREQ                     0x001d
>  #define EEPROM_FREQ_OFFSET             FIELD16(0x00ff)
>  #define EEPROM_FREQ_LED_MODE           FIELD16(0x7f00)
>  #define EEPROM_FREQ_LED_POLARITY       FIELD16(0x1000)
> @@ -2298,9 +2326,6 @@ struct mac_iveiv_entry {
>   * POLARITY_GPIO_4: Polarity GPIO4 setting.
>   * LED_MODE: Led mode.
>   */
> -#define EEPROM_LED_AG_CONF             0x001e
> -#define EEPROM_LED_ACT_CONF            0x001f
> -#define EEPROM_LED_POLARITY            0x0020
>  #define EEPROM_LED_POLARITY_RDY_BG     FIELD16(0x0001)
>  #define EEPROM_LED_POLARITY_RDY_A      FIELD16(0x0002)
>  #define EEPROM_LED_POLARITY_ACT                FIELD16(0x0004)
> @@ -2317,7 +2342,6 @@ struct mac_iveiv_entry {
>   * TX_STREAM: 0: Reserved, 1: 1 Stream, 2: 2 Stream
>   * CRYSTAL: 00: Reserved, 01: One crystal, 10: Two crystal, 11: Reserved
>   */
> -#define EEPROM_NIC_CONF2               0x0021
>  #define EEPROM_NIC_CONF2_RX_STREAM             FIELD16(0x000f)
>  #define EEPROM_NIC_CONF2_TX_STREAM             FIELD16(0x00f0)
>  #define EEPROM_NIC_CONF2_CRYSTAL               FIELD16(0x0600)
> @@ -2325,54 +2349,46 @@ struct mac_iveiv_entry {
>  /*
>   * EEPROM LNA
>   */
> -#define EEPROM_LNA                     0x0022
>  #define EEPROM_LNA_BG                  FIELD16(0x00ff)
>  #define EEPROM_LNA_A0                  FIELD16(0xff00)
>
>  /*
>   * EEPROM RSSI BG offset
>   */
> -#define EEPROM_RSSI_BG                 0x0023
>  #define EEPROM_RSSI_BG_OFFSET0         FIELD16(0x00ff)
>  #define EEPROM_RSSI_BG_OFFSET1         FIELD16(0xff00)
>
>  /*
>   * EEPROM RSSI BG2 offset
>   */
> -#define EEPROM_RSSI_BG2                        0x0024
>  #define EEPROM_RSSI_BG2_OFFSET2                FIELD16(0x00ff)
>  #define EEPROM_RSSI_BG2_LNA_A1         FIELD16(0xff00)
>
>  /*
>   * EEPROM TXMIXER GAIN BG offset (note overlaps with EEPROM RSSI BG2).
>   */
> -#define EEPROM_TXMIXER_GAIN_BG         0x0024
>  #define EEPROM_TXMIXER_GAIN_BG_VAL     FIELD16(0x0007)
>
>  /*
>   * EEPROM RSSI A offset
>   */
> -#define EEPROM_RSSI_A                  0x0025
>  #define EEPROM_RSSI_A_OFFSET0          FIELD16(0x00ff)
>  #define EEPROM_RSSI_A_OFFSET1          FIELD16(0xff00)
>
>  /*
>   * EEPROM RSSI A2 offset
>   */
> -#define EEPROM_RSSI_A2                 0x0026
>  #define EEPROM_RSSI_A2_OFFSET2         FIELD16(0x00ff)
>  #define EEPROM_RSSI_A2_LNA_A2          FIELD16(0xff00)
>
>  /*
>   * EEPROM TXMIXER GAIN A offset (note overlaps with EEPROM RSSI A2).
>   */
> -#define EEPROM_TXMIXER_GAIN_A          0x0026
>  #define EEPROM_TXMIXER_GAIN_A_VAL      FIELD16(0x0007)
>
>  /*
>   * EEPROM EIRP Maximum TX power values(unit: dbm)
>   */
> -#define EEPROM_EIRP_MAX_TX_POWER       0x0027
>  #define EEPROM_EIRP_MAX_TX_POWER_2GHZ  FIELD16(0x00ff)
>  #define EEPROM_EIRP_MAX_TX_POWER_5GHZ  FIELD16(0xff00)
>
> @@ -2383,7 +2399,6 @@ struct mac_iveiv_entry {
>   * TYPE: 1: Plus the delta value, 0: minus the delta value
>   * ENABLE: enable tx power compensation for 40BW
>   */
> -#define EEPROM_TXPOWER_DELTA           0x0028
>  #define EEPROM_TXPOWER_DELTA_VALUE_2G  FIELD16(0x003f)
>  #define EEPROM_TXPOWER_DELTA_TYPE_2G   FIELD16(0x0040)
>  #define EEPROM_TXPOWER_DELTA_ENABLE_2G FIELD16(0x0080)
> @@ -2394,8 +2409,6 @@ struct mac_iveiv_entry {
>  /*
>   * EEPROM TXPOWER 802.11BG
>   */
> -#define        EEPROM_TXPOWER_BG1              0x0029
> -#define        EEPROM_TXPOWER_BG2              0x0030
>  #define EEPROM_TXPOWER_BG_SIZE         7
>  #define EEPROM_TXPOWER_BG_1            FIELD16(0x00ff)
>  #define EEPROM_TXPOWER_BG_2            FIELD16(0xff00)
> @@ -2407,7 +2420,6 @@ struct mac_iveiv_entry {
>   * MINUS3: If the actual TSSI is below this boundary, tx power needs to be
>   *         reduced by (agc_step * -3)
>   */
> -#define EEPROM_TSSI_BOUND_BG1          0x0037
>  #define EEPROM_TSSI_BOUND_BG1_MINUS4   FIELD16(0x00ff)
>  #define EEPROM_TSSI_BOUND_BG1_MINUS3   FIELD16(0xff00)
>
> @@ -2418,7 +2430,6 @@ struct mac_iveiv_entry {
>   * MINUS1: If the actual TSSI is below this boundary, tx power needs to be
>   *         reduced by (agc_step * -1)
>   */
> -#define EEPROM_TSSI_BOUND_BG2          0x0038
>  #define EEPROM_TSSI_BOUND_BG2_MINUS2   FIELD16(0x00ff)
>  #define EEPROM_TSSI_BOUND_BG2_MINUS1   FIELD16(0xff00)
>
> @@ -2428,7 +2439,6 @@ struct mac_iveiv_entry {
>   * PLUS1: If the actual TSSI is above this boundary, tx power needs to be
>   *        increased by (agc_step * 1)
>   */
> -#define EEPROM_TSSI_BOUND_BG3          0x0039
>  #define EEPROM_TSSI_BOUND_BG3_REF      FIELD16(0x00ff)
>  #define EEPROM_TSSI_BOUND_BG3_PLUS1    FIELD16(0xff00)
>
> @@ -2439,7 +2449,6 @@ struct mac_iveiv_entry {
>   * PLUS3: If the actual TSSI is above this boundary, tx power needs to be
>   *        increased by (agc_step * 3)
>   */
> -#define EEPROM_TSSI_BOUND_BG4          0x003a
>  #define EEPROM_TSSI_BOUND_BG4_PLUS2    FIELD16(0x00ff)
>  #define EEPROM_TSSI_BOUND_BG4_PLUS3    FIELD16(0xff00)
>
> @@ -2449,15 +2458,12 @@ struct mac_iveiv_entry {
>   *        increased by (agc_step * 4)
>   * AGC_STEP: Temperature compensation step.
>   */
> -#define EEPROM_TSSI_BOUND_BG5          0x003b
>  #define EEPROM_TSSI_BOUND_BG5_PLUS4    FIELD16(0x00ff)
>  #define EEPROM_TSSI_BOUND_BG5_AGC_STEP FIELD16(0xff00)
>
>  /*
>   * EEPROM TXPOWER 802.11A
>   */
> -#define EEPROM_TXPOWER_A1              0x003c
> -#define EEPROM_TXPOWER_A2              0x0053
>  #define EEPROM_TXPOWER_A_SIZE          6
>  #define EEPROM_TXPOWER_A_1             FIELD16(0x00ff)
>  #define EEPROM_TXPOWER_A_2             FIELD16(0xff00)
> @@ -2469,7 +2475,6 @@ struct mac_iveiv_entry {
>   * MINUS3: If the actual TSSI is below this boundary, tx power needs to be
>   *         reduced by (agc_step * -3)
>   */
> -#define EEPROM_TSSI_BOUND_A1           0x006a
>  #define EEPROM_TSSI_BOUND_A1_MINUS4    FIELD16(0x00ff)
>  #define EEPROM_TSSI_BOUND_A1_MINUS3    FIELD16(0xff00)
>
> @@ -2480,7 +2485,6 @@ struct mac_iveiv_entry {
>   * MINUS1: If the actual TSSI is below this boundary, tx power needs to be
>   *         reduced by (agc_step * -1)
>   */
> -#define EEPROM_TSSI_BOUND_A2           0x006b
>  #define EEPROM_TSSI_BOUND_A2_MINUS2    FIELD16(0x00ff)
>  #define EEPROM_TSSI_BOUND_A2_MINUS1    FIELD16(0xff00)
>
> @@ -2490,7 +2494,6 @@ struct mac_iveiv_entry {
>   * PLUS1: If the actual TSSI is above this boundary, tx power needs to be
>   *        increased by (agc_step * 1)
>   */
> -#define EEPROM_TSSI_BOUND_A3           0x006c
>  #define EEPROM_TSSI_BOUND_A3_REF       FIELD16(0x00ff)
>  #define EEPROM_TSSI_BOUND_A3_PLUS1     FIELD16(0xff00)
>
> @@ -2501,7 +2504,6 @@ struct mac_iveiv_entry {
>   * PLUS3: If the actual TSSI is above this boundary, tx power needs to be
>   *        increased by (agc_step * 3)
>   */
> -#define EEPROM_TSSI_BOUND_A4           0x006d
>  #define EEPROM_TSSI_BOUND_A4_PLUS2     FIELD16(0x00ff)
>  #define EEPROM_TSSI_BOUND_A4_PLUS3     FIELD16(0xff00)
>
> @@ -2511,14 +2513,12 @@ struct mac_iveiv_entry {
>   *        increased by (agc_step * 4)
>   * AGC_STEP: Temperature compensation step.
>   */
> -#define EEPROM_TSSI_BOUND_A5           0x006e
>  #define EEPROM_TSSI_BOUND_A5_PLUS4     FIELD16(0x00ff)
>  #define EEPROM_TSSI_BOUND_A5_AGC_STEP  FIELD16(0xff00)
>
>  /*
>   * EEPROM TXPOWER by rate: tx power per tx rate for HT20 mode
>   */
> -#define EEPROM_TXPOWER_BYRATE          0x006f
>  #define EEPROM_TXPOWER_BYRATE_SIZE     9
>
>  #define EEPROM_TXPOWER_BYRATE_RATE0    FIELD16(0x000f)
> @@ -2529,7 +2529,6 @@ struct mac_iveiv_entry {
>  /*
>   * EEPROM BBP.
>   */
> -#define        EEPROM_BBP_START                0x0078
>  #define EEPROM_BBP_SIZE                        16
>  #define EEPROM_BBP_VALUE               FIELD16(0x00ff)
>  #define EEPROM_BBP_REG_ID              FIELD16(0xff00)
> --
> 1.7.10
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



--
---
Gertjan

^ permalink raw reply

* Re: [PATCH] brcm: add brcmfmac sdio firmware for bcm43241
From: Arend van Spriel @ 2013-07-08  9:29 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: Linux Wireless, Franky Lin, David Woodhouse, Stephen Warren
In-Reply-To: <1373125142.22888.113.camel@deadeye.wl.decadent.org.uk>

On 07/06/2013 05:39 PM, Ben Hutchings wrote:
> On Thu, 2013-07-04 at 12:34 +0200, Arend van Spriel wrote:
>> On 07/04/2013 04:22 AM, Ben Hutchings wrote:
>>> On Wed, 2013-05-29 at 15:13 +0200, Arend van Spriel wrote:
> [...]
>>>> --- a/WHENCE
>>>> +++ b/WHENCE
>>>> @@ -1652,6 +1652,7 @@ Driver: brcmfmac - Broadcom 802.11n fullmac wireless LAN driver.
>>>>
>>>>    File: brcm/bcm4329-fullmac-4.bin
>>>>    File: brcm/brcmfmac43236b.bin
>>>> +File: brcm/brcmfmac43241.bin
>>>>    File: brcm/brcmfmac4329.bin
>>>>    File: brcm/brcmfmac4330.bin
>>>>    File: brcm/brcmfmac4334.bin
>>> [...]
>>>
>>> Unless you're doing something very clever with macros, I don't believe
>>> you've posted any driver code that uses this file... or several of the
>>> others.  The current driver in net-next (I don't know what you've sent
>>> to Nvidia) appears to request only these files:
>>
>> Hi, Ben
>>
>> Nvidia was just using the upstream brcmfmac driver. The "clever" thing
>> we are doing for the SDIO part of our brcmfmac driver is that the
>> firmware filename requested by the driver is always brcmfmac-sdio.bin.
>> We explain on wireless.kernel.org that people should link/copy the
>> firmware file for their device to brcmfmac-sdio.bin
>
> Not a great idea, but I think you recognise that now.
>
>> and get
>> brcmfmac-sdio.txt from their board supplier as it is very board specific
>> initialization data.
>
> What if someone wants to put more than one of these devices in the same
> system?

It is the same issue as the firmware.

> [...]
>>> So I think, before this patch is applied, you owe me and David patches
>>> to:
>>>
>>> 1. Add brcm/brcmfmac43143.bin, brcm/brcmfmac43242a.bin and
>>> brcm/brcmfmac-sdio.txt.
>>
>> The 43143 and 43242 bin files will be submitted, but these firmwares
>> have not yet been released. I have to wait for a green light on that.
>>
>>> 2. Rename brcm/bcm4329-fullmac-4.bin to brcm/brcmfmac-sdio.bin.
>>
>> That file is there for brcmfmac in older kernels (< v3.3) as the
>> replacement brcmfmac4329.bin does not work with brcmfmac in those older
>> kernels.
>
> OK.
>
>>> 3. Add symlinks from all the old names to the new names.  (As
>>> linux-firmware should support old in-tree drivers indefinitely.)
>>
>> I will look into this to see what names were used by brcmfmac since it
>> was mainlined.
>
> As I said, all the names that have been used should be supported.  So
> either provide multiple versions of the firmware or add symlinks, as
> appropriate.

Will do.

>>> and you owe linux-wireless some driver patches.
>>>
>>> linux-firmware.git is not the appropriate place to send firmware used
>>> only by out-of-tree code, and any firmware blob that has never been
>>> referenced by in-tree code is subject to removal.
>>
>> I am aware and none of the firmwares we released are for out-of-tree
>> code. We actually got feedback that using the same firmware filename for
>> multiple devices was not very user-friendly. Therefore we will get rid
>> of this quirky approach in the next kernel and the firmware files in
>> linux-firmware will be listed in brcmfmac using the MODULE_FIRMWARE() macro.
>
> Thanks for clearing this up.
>
> Please re-send the new firmware, and include the firmware version in
> WHENCE.

I will prepare patches to address item #3 above and to add the new firmware.

Thanks,
Arend



^ permalink raw reply

* Re: [rt2x00-users] [PATCH 4/5] rt2x00: rt2800lib: introduce rt2800_eeprom_word_index helper
From: Gabor Juhos @ 2013-07-08  9:26 UTC (permalink / raw)
  To: Stanislaw Gruszka; +Cc: John Linville, linux-wireless, users
In-Reply-To: <20130704182746.GA2061@localhost.localdomain>

Hi Stanislaw,

> On Wed, Jul 03, 2013 at 10:23:26PM +0200, Gabor Juhos wrote:
>>> I have two nit-picks, but they can be fixed later on top of your current
>>> patches.
>>>
>>>> +	if (WARN_ON(word >= EEPROM_WORD_COUNT)) {
>>>> +		rt2x00_warn(rt2x00dev, "invalid EEPROM word %d\n", word);
>>>> +		return 0;
>>>> +	}
>>>
>>> Since we take "enum rt2800_eeprom_word" as word argument, it can not
>>> have different values than already listed, so this warning is not needed.
>>
>> EEPROM_WORD_COUNT is listed in the enums and the word argument can be equal to
>> that, however it is not a valid index for the EEPROM map. Additionally, if
>> someone puts a new enum value after EEPROM_WORD_COUNT by mistake that will be an
>> invalid index as well.
> 
> I do not feel that there is big chance that someone will do such
> mistakes, but yes, they are at least theoretically possible, so warning
> can stay.
> 
>> My reason behind the rt2x00_warn call was that it shows the wiphy name. If you
>> are testing different devices in parallel it is good to know which one causes
>> the warning. However I can use 'wiphy_name(rt2x00dev->hw->wiphy)' to get that
>> information.
>>
>> I will send a follow-up patch which removes the rt2x00_warn calls. Do you also
>> prefer WARN_ONCE instead of WARN?
> 
> I prefer WARN_ONCE variant to avoid possible spamming dmesg with lot of
> warnings.

Ok. Because the patch-set has not been integrated yet, I have sent an updated
version instead of a follow-up patch.

-Gabor


^ permalink raw reply

* [PATCH v2 4/5] rt2x00: rt2800lib: introduce rt2800_eeprom_word_index helper
From: Gabor Juhos @ 2013-07-08  9:25 UTC (permalink / raw)
  To: John Linville; +Cc: linux-wireless, users, Gabor Juhos
In-Reply-To: <1373275556-6482-1-git-send-email-juhosg@openwrt.org>

Instead of assign the offset value to the
enum directly use a new helper function to
convert a rt2800_eeprom_word enum into an
index of the rt2x00_dev->eeprom array.

The patch does not change the existing
behaviour, but makes it possible to add
support for three-chain devices which are
using a different EEPROM layout.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
Changes since v1:
  - use WARN_ONCE and remove the rt2x00_warn calls
---
 drivers/net/wireless/rt2x00/rt2800.h    |   76 ++++++++++++++-------------
 drivers/net/wireless/rt2x00/rt2800lib.c |   87 +++++++++++++++++++++++++++++--
 2 files changed, 122 insertions(+), 41 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h
index 0647039..bc5c695 100644
--- a/drivers/net/wireless/rt2x00/rt2800.h
+++ b/drivers/net/wireless/rt2x00/rt2800.h
@@ -2207,43 +2207,45 @@ struct mac_iveiv_entry {
  */
 
 enum rt2800_eeprom_word {
-	EEPROM_CHIP_ID		= 0x0000,
-	EEPROM_VERSION		= 0x0001,
-	EEPROM_MAC_ADDR_0	= 0x0002,
-	EEPROM_MAC_ADDR_1	= 0x0003,
-	EEPROM_MAC_ADDR_2	= 0x0004,
-	EEPROM_NIC_CONF0	= 0x001a,
-	EEPROM_NIC_CONF1	= 0x001b,
-	EEPROM_FREQ		= 0x001d,
-	EEPROM_LED_AG_CONF	= 0x001e,
-	EEPROM_LED_ACT_CONF	= 0x001f,
-	EEPROM_LED_POLARITY	= 0x0020,
-	EEPROM_NIC_CONF2	= 0x0021,
-	EEPROM_LNA		= 0x0022,
-	EEPROM_RSSI_BG		= 0x0023,
-	EEPROM_RSSI_BG2		= 0x0024,
-	EEPROM_TXMIXER_GAIN_BG	= 0x0024, /* overlaps with RSSI_BG2 */
-	EEPROM_RSSI_A		= 0x0025,
-	EEPROM_RSSI_A2		= 0x0026,
-	EEPROM_TXMIXER_GAIN_A	= 0x0026, /* overlaps with RSSI_A2 */
-	EEPROM_EIRP_MAX_TX_POWER = 0x0027,
-	EEPROM_TXPOWER_DELTA	= 0x0028,
-	EEPROM_TXPOWER_BG1	= 0x0029,
-	EEPROM_TXPOWER_BG2	= 0x0030,
-	EEPROM_TSSI_BOUND_BG1	= 0x0037,
-	EEPROM_TSSI_BOUND_BG2	= 0x0038,
-	EEPROM_TSSI_BOUND_BG3	= 0x0039,
-	EEPROM_TSSI_BOUND_BG4	= 0x003a,
-	EEPROM_TSSI_BOUND_BG5	= 0x003b,
-	EEPROM_TXPOWER_A1	= 0x003c,
-	EEPROM_TXPOWER_A2	= 0x0053,
-	EEPROM_TSSI_BOUND_A1	= 0x006a,
-	EEPROM_TSSI_BOUND_A2	= 0x006b,
-	EEPROM_TSSI_BOUND_A3	= 0x006c,
-	EEPROM_TSSI_BOUND_A4	= 0x006d,
-	EEPROM_TSSI_BOUND_A5	= 0x006e,
-	EEPROM_TXPOWER_BYRATE	= 0x006f,
-	EEPROM_BBP_START	= 0x0078,
+	EEPROM_CHIP_ID = 0,
+	EEPROM_VERSION,
+	EEPROM_MAC_ADDR_0,
+	EEPROM_MAC_ADDR_1,
+	EEPROM_MAC_ADDR_2,
+	EEPROM_NIC_CONF0,
+	EEPROM_NIC_CONF1,
+	EEPROM_FREQ,
+	EEPROM_LED_AG_CONF,
+	EEPROM_LED_ACT_CONF,
+	EEPROM_LED_POLARITY,
+	EEPROM_NIC_CONF2,
+	EEPROM_LNA,
+	EEPROM_RSSI_BG,
+	EEPROM_RSSI_BG2,
+	EEPROM_TXMIXER_GAIN_BG,
+	EEPROM_RSSI_A,
+	EEPROM_RSSI_A2,
+	EEPROM_TXMIXER_GAIN_A,
+	EEPROM_EIRP_MAX_TX_POWER,
+	EEPROM_TXPOWER_DELTA,
+	EEPROM_TXPOWER_BG1,
+	EEPROM_TXPOWER_BG2,
+	EEPROM_TSSI_BOUND_BG1,
+	EEPROM_TSSI_BOUND_BG2,
+	EEPROM_TSSI_BOUND_BG3,
+	EEPROM_TSSI_BOUND_BG4,
+	EEPROM_TSSI_BOUND_BG5,
+	EEPROM_TXPOWER_A1,
+	EEPROM_TXPOWER_A2,
+	EEPROM_TSSI_BOUND_A1,
+	EEPROM_TSSI_BOUND_A2,
+	EEPROM_TSSI_BOUND_A3,
+	EEPROM_TSSI_BOUND_A4,
+	EEPROM_TSSI_BOUND_A5,
+	EEPROM_TXPOWER_BYRATE,
+	EEPROM_BBP_START,
+	/* New values must be added before this */
+	EEPROM_WORD_COUNT
 };
 
 /*
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index b59772a..41a34de4a 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -221,22 +221,98 @@ static void rt2800_rf_write(struct rt2x00_dev *rt2x00dev,
 	mutex_unlock(&rt2x00dev->csr_mutex);
 }
 
+static const unsigned int rt2800_eeprom_map[EEPROM_WORD_COUNT] = {
+	[EEPROM_CHIP_ID]		= 0x0000,
+	[EEPROM_VERSION]		= 0x0001,
+	[EEPROM_MAC_ADDR_0]		= 0x0002,
+	[EEPROM_MAC_ADDR_1]		= 0x0003,
+	[EEPROM_MAC_ADDR_2]		= 0x0004,
+	[EEPROM_NIC_CONF0]		= 0x001a,
+	[EEPROM_NIC_CONF1]		= 0x001b,
+	[EEPROM_FREQ]			= 0x001d,
+	[EEPROM_LED_AG_CONF]		= 0x001e,
+	[EEPROM_LED_ACT_CONF]		= 0x001f,
+	[EEPROM_LED_POLARITY]		= 0x0020,
+	[EEPROM_NIC_CONF2]		= 0x0021,
+	[EEPROM_LNA]			= 0x0022,
+	[EEPROM_RSSI_BG]		= 0x0023,
+	[EEPROM_RSSI_BG2]		= 0x0024,
+	[EEPROM_TXMIXER_GAIN_BG]	= 0x0024, /* overlaps with RSSI_BG2 */
+	[EEPROM_RSSI_A]			= 0x0025,
+	[EEPROM_RSSI_A2]		= 0x0026,
+	[EEPROM_TXMIXER_GAIN_A]		= 0x0026, /* overlaps with RSSI_A2 */
+	[EEPROM_EIRP_MAX_TX_POWER]	= 0x0027,
+	[EEPROM_TXPOWER_DELTA]		= 0x0028,
+	[EEPROM_TXPOWER_BG1]		= 0x0029,
+	[EEPROM_TXPOWER_BG2]		= 0x0030,
+	[EEPROM_TSSI_BOUND_BG1]		= 0x0037,
+	[EEPROM_TSSI_BOUND_BG2]		= 0x0038,
+	[EEPROM_TSSI_BOUND_BG3]		= 0x0039,
+	[EEPROM_TSSI_BOUND_BG4]		= 0x003a,
+	[EEPROM_TSSI_BOUND_BG5]		= 0x003b,
+	[EEPROM_TXPOWER_A1]		= 0x003c,
+	[EEPROM_TXPOWER_A2]		= 0x0053,
+	[EEPROM_TSSI_BOUND_A1]		= 0x006a,
+	[EEPROM_TSSI_BOUND_A2]		= 0x006b,
+	[EEPROM_TSSI_BOUND_A3]		= 0x006c,
+	[EEPROM_TSSI_BOUND_A4]		= 0x006d,
+	[EEPROM_TSSI_BOUND_A5]		= 0x006e,
+	[EEPROM_TXPOWER_BYRATE]		= 0x006f,
+	[EEPROM_BBP_START]		= 0x0078,
+};
+
+static unsigned int rt2800_eeprom_word_index(struct rt2x00_dev *rt2x00dev,
+					     const enum rt2800_eeprom_word word)
+{
+	const unsigned int *map;
+	unsigned int index;
+
+	if (WARN_ONCE(word >= EEPROM_WORD_COUNT,
+		      "%s: invalid EEPROM word %d\n",
+		      wiphy_name(rt2x00dev->hw->wiphy), word))
+		return 0;
+
+	map = rt2800_eeprom_map;
+	index = map[word];
+
+	/* Index 0 is valid only for EEPROM_CHIP_ID.
+	 * Otherwise it means that the offset of the
+	 * given word is not initialized in the map,
+	 * or that the field is not usable on the
+	 * actual chipset.
+	 */
+	WARN_ONCE(word != EEPROM_CHIP_ID && index == 0,
+		  "%s: invalid access of EEPROM word %d\n",
+		  wiphy_name(rt2x00dev->hw->wiphy), word);
+
+	return index;
+}
+
 static void *rt2800_eeprom_addr(struct rt2x00_dev *rt2x00dev,
 				const enum rt2800_eeprom_word word)
 {
-	return rt2x00_eeprom_addr(rt2x00dev, word);
+	unsigned int index;
+
+	index = rt2800_eeprom_word_index(rt2x00dev, word);
+	return rt2x00_eeprom_addr(rt2x00dev, index);
 }
 
 static void rt2800_eeprom_read(struct rt2x00_dev *rt2x00dev,
 			       const enum rt2800_eeprom_word word, u16 *data)
 {
-	rt2x00_eeprom_read(rt2x00dev, word, data);
+	unsigned int index;
+
+	index = rt2800_eeprom_word_index(rt2x00dev, word);
+	rt2x00_eeprom_read(rt2x00dev, index, data);
 }
 
 static void rt2800_eeprom_write(struct rt2x00_dev *rt2x00dev,
 				const enum rt2800_eeprom_word word, u16 data)
 {
-	rt2x00_eeprom_write(rt2x00dev, word, data);
+	unsigned int index;
+
+	index = rt2800_eeprom_word_index(rt2x00dev, word);
+	rt2x00_eeprom_write(rt2x00dev, index, data);
 }
 
 static void rt2800_eeprom_read_from_array(struct rt2x00_dev *rt2x00dev,
@@ -244,7 +320,10 @@ static void rt2800_eeprom_read_from_array(struct rt2x00_dev *rt2x00dev,
 					  unsigned int offset,
 					  u16 *data)
 {
-	rt2x00_eeprom_read(rt2x00dev, array + offset, data);
+	unsigned int index;
+
+	index = rt2800_eeprom_word_index(rt2x00dev, array);
+	rt2x00_eeprom_read(rt2x00dev, index + offset, data);
 }
 
 static int rt2800_enable_wlan_rt3290(struct rt2x00_dev *rt2x00dev)
-- 
1.7.10


^ permalink raw reply related

* [PATCH v2 5/5] rt2x00: rt2800lib: add EEPROM map for the RT3593 chipset
From: Gabor Juhos @ 2013-07-08  9:25 UTC (permalink / raw)
  To: John Linville; +Cc: linux-wireless, users, Gabor Juhos
In-Reply-To: <1373275556-6482-1-git-send-email-juhosg@openwrt.org>

Three-chain devices are using a different
EEPROM layout than the rest of the chipsets.
Add a new map which describes the new layout
and use that for the RT3593 chipset.

The index values has been computed from the
EEPROM_EXT_* defines, which can be found in
the 'include/chip/rt3593.h' file in the
Ralink DPO_RT5572_LinuxSTA_2.6.0.1_20120629
driver.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>
---
Changes since v1: ---
---
 drivers/net/wireless/rt2x00/rt2800.h    |    6 ++++
 drivers/net/wireless/rt2x00/rt2800lib.c |   48 ++++++++++++++++++++++++++++++-
 2 files changed, 53 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h
index bc5c695..9216834 100644
--- a/drivers/net/wireless/rt2x00/rt2800.h
+++ b/drivers/net/wireless/rt2x00/rt2800.h
@@ -2244,6 +2244,12 @@ enum rt2800_eeprom_word {
 	EEPROM_TSSI_BOUND_A5,
 	EEPROM_TXPOWER_BYRATE,
 	EEPROM_BBP_START,
+
+	/* IDs for extended EEPROM format used by three-chain devices */
+	EEPROM_EXT_LNA2,
+	EEPROM_EXT_TXPOWER_BG3,
+	EEPROM_EXT_TXPOWER_A3,
+
 	/* New values must be added before this */
 	EEPROM_WORD_COUNT
 };
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 41a34de4a..d325ca2 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -261,6 +261,48 @@ static const unsigned int rt2800_eeprom_map[EEPROM_WORD_COUNT] = {
 	[EEPROM_BBP_START]		= 0x0078,
 };
 
+static const unsigned int rt2800_eeprom_map_ext[EEPROM_WORD_COUNT] = {
+	[EEPROM_CHIP_ID]		= 0x0000,
+	[EEPROM_VERSION]		= 0x0001,
+	[EEPROM_MAC_ADDR_0]		= 0x0002,
+	[EEPROM_MAC_ADDR_1]		= 0x0003,
+	[EEPROM_MAC_ADDR_2]		= 0x0004,
+	[EEPROM_NIC_CONF0]		= 0x001a,
+	[EEPROM_NIC_CONF1]		= 0x001b,
+	[EEPROM_NIC_CONF2]		= 0x001c,
+	[EEPROM_EIRP_MAX_TX_POWER]	= 0x0020,
+	[EEPROM_FREQ]			= 0x0022,
+	[EEPROM_LED_AG_CONF]		= 0x0023,
+	[EEPROM_LED_ACT_CONF]		= 0x0024,
+	[EEPROM_LED_POLARITY]		= 0x0025,
+	[EEPROM_LNA]			= 0x0026,
+	[EEPROM_EXT_LNA2]		= 0x0027,
+	[EEPROM_RSSI_BG]		= 0x0028,
+	[EEPROM_TXPOWER_DELTA]		= 0x0028, /* Overlaps with RSSI_BG */
+	[EEPROM_RSSI_BG2]		= 0x0029,
+	[EEPROM_TXMIXER_GAIN_BG]	= 0x0029, /* Overlaps with RSSI_BG2 */
+	[EEPROM_RSSI_A]			= 0x002a,
+	[EEPROM_RSSI_A2]		= 0x002b,
+	[EEPROM_TXMIXER_GAIN_A]		= 0x002b, /* Overlaps with RSSI_A2 */
+	[EEPROM_TXPOWER_BG1]		= 0x0030,
+	[EEPROM_TXPOWER_BG2]		= 0x0037,
+	[EEPROM_EXT_TXPOWER_BG3]	= 0x003e,
+	[EEPROM_TSSI_BOUND_BG1]		= 0x0045,
+	[EEPROM_TSSI_BOUND_BG2]		= 0x0046,
+	[EEPROM_TSSI_BOUND_BG3]		= 0x0047,
+	[EEPROM_TSSI_BOUND_BG4]		= 0x0048,
+	[EEPROM_TSSI_BOUND_BG5]		= 0x0049,
+	[EEPROM_TXPOWER_A1]		= 0x004b,
+	[EEPROM_TXPOWER_A2]		= 0x0065,
+	[EEPROM_EXT_TXPOWER_A3]		= 0x007f,
+	[EEPROM_TSSI_BOUND_A1]		= 0x009a,
+	[EEPROM_TSSI_BOUND_A2]		= 0x009b,
+	[EEPROM_TSSI_BOUND_A3]		= 0x009c,
+	[EEPROM_TSSI_BOUND_A4]		= 0x009d,
+	[EEPROM_TSSI_BOUND_A5]		= 0x009e,
+	[EEPROM_TXPOWER_BYRATE]		= 0x00a0,
+};
+
 static unsigned int rt2800_eeprom_word_index(struct rt2x00_dev *rt2x00dev,
 					     const enum rt2800_eeprom_word word)
 {
@@ -272,7 +314,11 @@ static unsigned int rt2800_eeprom_word_index(struct rt2x00_dev *rt2x00dev,
 		      wiphy_name(rt2x00dev->hw->wiphy), word))
 		return 0;
 
-	map = rt2800_eeprom_map;
+	if (rt2x00_rt(rt2x00dev, RT3593))
+		map = rt2800_eeprom_map_ext;
+	else
+		map = rt2800_eeprom_map;
+
 	index = map[word];
 
 	/* Index 0 is valid only for EEPROM_CHIP_ID.
-- 
1.7.10


^ permalink raw reply related

* [PATCH v2 2/5] rt2x00: rt2800lib: introduce local EEPROM access functions
From: Gabor Juhos @ 2013-07-08  9:25 UTC (permalink / raw)
  To: John Linville; +Cc: linux-wireless, users, Gabor Juhos
In-Reply-To: <1373275556-6482-1-git-send-email-juhosg@openwrt.org>

The patch adds rt2800 specific functions for
EEPROM data access and changes the code to use
these instead of the generic rt2x00_eeprom_*
variants.

To avoid functional changes, the new functions
are wrappers around the corresponding generic
rt2x00_eeprom_* routines for now. Functional
changes will be implemented in additional patches.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>
---
Changes since v1: ---
---
 drivers/net/wireless/rt2x00/rt2800lib.c |  165 ++++++++++++++++++-------------
 1 file changed, 95 insertions(+), 70 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 1f80ea5..522f0b1 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -221,6 +221,24 @@ static void rt2800_rf_write(struct rt2x00_dev *rt2x00dev,
 	mutex_unlock(&rt2x00dev->csr_mutex);
 }
 
+static void *rt2800_eeprom_addr(struct rt2x00_dev *rt2x00dev,
+				const enum rt2800_eeprom_word word)
+{
+	return rt2x00_eeprom_addr(rt2x00dev, word);
+}
+
+static void rt2800_eeprom_read(struct rt2x00_dev *rt2x00dev,
+			       const enum rt2800_eeprom_word word, u16 *data)
+{
+	rt2x00_eeprom_read(rt2x00dev, word, data);
+}
+
+static void rt2800_eeprom_write(struct rt2x00_dev *rt2x00dev,
+				const enum rt2800_eeprom_word word, u16 data)
+{
+	rt2x00_eeprom_write(rt2x00dev, word, data);
+}
+
 static int rt2800_enable_wlan_rt3290(struct rt2x00_dev *rt2x00dev)
 {
 	u32 reg;
@@ -609,16 +627,16 @@ static int rt2800_agc_to_rssi(struct rt2x00_dev *rt2x00dev, u32 rxwi_w2)
 	u8 offset2;
 
 	if (rt2x00dev->curr_band == IEEE80211_BAND_2GHZ) {
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_BG, &eeprom);
 		offset0 = rt2x00_get_field16(eeprom, EEPROM_RSSI_BG_OFFSET0);
 		offset1 = rt2x00_get_field16(eeprom, EEPROM_RSSI_BG_OFFSET1);
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &eeprom);
 		offset2 = rt2x00_get_field16(eeprom, EEPROM_RSSI_BG2_OFFSET2);
 	} else {
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_A, &eeprom);
 		offset0 = rt2x00_get_field16(eeprom, EEPROM_RSSI_A_OFFSET0);
 		offset1 = rt2x00_get_field16(eeprom, EEPROM_RSSI_A_OFFSET1);
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &eeprom);
 		offset2 = rt2x00_get_field16(eeprom, EEPROM_RSSI_A2_OFFSET2);
 	}
 
@@ -890,6 +908,9 @@ const struct rt2x00debug rt2800_rt2x00debug = {
 		.word_count	= CSR_REG_SIZE / sizeof(u32),
 	},
 	.eeprom	= {
+		/* NOTE: The local EEPROM access functions can't
+		 * be used here, use the generic versions instead.
+		 */
 		.read		= rt2x00_eeprom_read,
 		.write		= rt2x00_eeprom_write,
 		.word_base	= EEPROM_BASE,
@@ -1547,7 +1568,7 @@ static void rt2800_config_3572bt_ant(struct rt2x00_dev *rt2x00dev)
 	led_r_mode = rt2x00_get_field32(reg, LED_CFG_LED_POLAR) ? 0 : 3;
 	if (led_g_mode != rt2x00_get_field32(reg, LED_CFG_G_LED_MODE) ||
 	    led_r_mode != rt2x00_get_field32(reg, LED_CFG_R_LED_MODE)) {
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_FREQ, &eeprom);
 		led_ctrl = rt2x00_get_field16(eeprom, EEPROM_FREQ_LED_MODE);
 		if (led_ctrl == 0 || led_ctrl > 0x40) {
 			rt2x00_set_field32(&reg, LED_CFG_G_LED_MODE, led_g_mode);
@@ -1622,7 +1643,7 @@ void rt2800_config_ant(struct rt2x00_dev *rt2x00dev, struct antenna_setup *ant)
 		    rt2x00_rt(rt2x00dev, RT3090) ||
 		    rt2x00_rt(rt2x00dev, RT3352) ||
 		    rt2x00_rt(rt2x00dev, RT3390)) {
-			rt2x00_eeprom_read(rt2x00dev,
+			rt2800_eeprom_read(rt2x00dev,
 					   EEPROM_NIC_CONF1, &eeprom);
 			if (rt2x00_get_field16(eeprom,
 						EEPROM_NIC_CONF1_ANT_DIVERSITY))
@@ -1659,16 +1680,16 @@ static void rt2800_config_lna_gain(struct rt2x00_dev *rt2x00dev,
 	short lna_gain;
 
 	if (libconf->rf.channel <= 14) {
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_LNA, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_LNA, &eeprom);
 		lna_gain = rt2x00_get_field16(eeprom, EEPROM_LNA_BG);
 	} else if (libconf->rf.channel <= 64) {
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_LNA, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_LNA, &eeprom);
 		lna_gain = rt2x00_get_field16(eeprom, EEPROM_LNA_A0);
 	} else if (libconf->rf.channel <= 128) {
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &eeprom);
 		lna_gain = rt2x00_get_field16(eeprom, EEPROM_RSSI_BG2_LNA_A1);
 	} else {
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &eeprom);
 		lna_gain = rt2x00_get_field16(eeprom, EEPROM_RSSI_A2_LNA_A2);
 	}
 
@@ -2798,62 +2819,62 @@ static int rt2800_get_gain_calibration_delta(struct rt2x00_dev *rt2x00dev)
 	 * Example TSSI bounds  0xF0 0xD0 0xB5 0xA0 0x88 0x45 0x25 0x15 0x00
 	 */
 	if (rt2x00dev->curr_band == IEEE80211_BAND_2GHZ) {
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG1, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG1, &eeprom);
 		tssi_bounds[0] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_BG1_MINUS4);
 		tssi_bounds[1] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_BG1_MINUS3);
 
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG2, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG2, &eeprom);
 		tssi_bounds[2] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_BG2_MINUS2);
 		tssi_bounds[3] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_BG2_MINUS1);
 
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG3, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG3, &eeprom);
 		tssi_bounds[4] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_BG3_REF);
 		tssi_bounds[5] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_BG3_PLUS1);
 
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG4, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG4, &eeprom);
 		tssi_bounds[6] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_BG4_PLUS2);
 		tssi_bounds[7] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_BG4_PLUS3);
 
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG5, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG5, &eeprom);
 		tssi_bounds[8] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_BG5_PLUS4);
 
 		step = rt2x00_get_field16(eeprom,
 					  EEPROM_TSSI_BOUND_BG5_AGC_STEP);
 	} else {
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A1, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A1, &eeprom);
 		tssi_bounds[0] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_A1_MINUS4);
 		tssi_bounds[1] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_A1_MINUS3);
 
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A2, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A2, &eeprom);
 		tssi_bounds[2] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_A2_MINUS2);
 		tssi_bounds[3] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_A2_MINUS1);
 
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A3, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A3, &eeprom);
 		tssi_bounds[4] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_A3_REF);
 		tssi_bounds[5] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_A3_PLUS1);
 
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A4, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A4, &eeprom);
 		tssi_bounds[6] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_A4_PLUS2);
 		tssi_bounds[7] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_A4_PLUS3);
 
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A5, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A5, &eeprom);
 		tssi_bounds[8] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_A5_PLUS4);
 
@@ -2899,7 +2920,7 @@ static int rt2800_get_txpower_bw_comp(struct rt2x00_dev *rt2x00dev,
 	u8 comp_type;
 	int comp_value = 0;
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_TXPOWER_DELTA, &eeprom);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_TXPOWER_DELTA, &eeprom);
 
 	/*
 	 * HT40 compensation not required.
@@ -2974,12 +2995,12 @@ static u8 rt2800_compensate_txpower(struct rt2x00_dev *rt2x00dev, int is_rate_b,
 		 * .11b data rate need add additional 4dbm
 		 * when calculating eirp txpower.
 		 */
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + 1,
+		rt2800_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + 1,
 				   &eeprom);
 		criterion = rt2x00_get_field16(eeprom,
 					       EEPROM_TXPOWER_BYRATE_RATE0);
 
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_EIRP_MAX_TX_POWER,
+		rt2800_eeprom_read(rt2x00dev, EEPROM_EIRP_MAX_TX_POWER,
 				   &eeprom);
 
 		if (band == IEEE80211_BAND_2GHZ)
@@ -3080,7 +3101,7 @@ static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev,
 		rt2800_register_read(rt2x00dev, offset, &reg);
 
 		/* read the next four txpower values */
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + i,
+		rt2800_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + i,
 				   &eeprom);
 
 		is_rate_b = i ? 0 : 1;
@@ -3129,7 +3150,7 @@ static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev,
 		rt2x00_set_field32(&reg, TX_PWR_CFG_RATE3, txpower);
 
 		/* read the next four txpower values */
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + i + 1,
+		rt2800_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + i + 1,
 				   &eeprom);
 
 		is_rate_b = 0;
@@ -3528,7 +3549,8 @@ static int rt2800_init_registers(struct rt2x00_dev *rt2x00dev)
 		if (rt2x00_rt_rev_lt(rt2x00dev, RT3071, REV_RT3071E) ||
 		    rt2x00_rt_rev_lt(rt2x00dev, RT3090, REV_RT3090E) ||
 		    rt2x00_rt_rev_lt(rt2x00dev, RT3390, REV_RT3390E)) {
-			rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
+			rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1,
+					   &eeprom);
 			if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_DAC_TEST))
 				rt2800_register_write(rt2x00dev, TX_SW_CFG2,
 						      0x0000002c);
@@ -3989,7 +4011,7 @@ static void rt2800_disable_unused_dac_adc(struct rt2x00_dev *rt2x00dev)
 	u8 value;
 
 	rt2800_bbp_read(rt2x00dev, 138, &value);
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
 	if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_TXPATH) == 1)
 		value |= 0x20;
 	if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH) == 1)
@@ -4402,7 +4424,7 @@ static void rt2800_init_bbp_53xx(struct rt2x00_dev *rt2x00dev)
 
 	rt2800_disable_unused_dac_adc(rt2x00dev);
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
 	div_mode = rt2x00_get_field16(eeprom,
 				      EEPROM_NIC_CONF1_ANT_DIVERSITY);
 	ant = (div_mode == 3) ? 1 : 0;
@@ -4488,7 +4510,7 @@ static void rt2800_init_bbp_5592(struct rt2x00_dev *rt2x00dev)
 
 	rt2800_bbp4_mac_if_ctrl(rt2x00dev);
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
 	div_mode = rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_ANT_DIVERSITY);
 	ant = (div_mode == 3) ? 1 : 0;
 	rt2800_bbp_read(rt2x00dev, 152, &value);
@@ -4557,7 +4579,7 @@ static void rt2800_init_bbp(struct rt2x00_dev *rt2x00dev)
 	}
 
 	for (i = 0; i < EEPROM_BBP_SIZE; i++) {
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_BBP_START + i, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_BBP_START + i, &eeprom);
 
 		if (eeprom != 0xffff && eeprom != 0x0000) {
 			reg_id = rt2x00_get_field16(eeprom, EEPROM_BBP_REG_ID);
@@ -4728,7 +4750,7 @@ static void rt2800_normal_mode_setup_3xxx(struct rt2x00_dev *rt2x00dev)
 	if (rt2x00_rt(rt2x00dev, RT3090)) {
 		/*  Turn off unused DAC1 and ADC1 to reduce power consumption */
 		rt2800_bbp_read(rt2x00dev, 138, &bbp);
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
 		if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH) == 1)
 			rt2x00_set_field8(&bbp, BBP138_RX_ADC1, 0);
 		if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_TXPATH) == 1)
@@ -4778,7 +4800,7 @@ static void rt2800_normal_mode_setup_5xxx(struct rt2x00_dev *rt2x00dev)
 
 	/*  Turn off unused DAC1 and ADC1 to reduce power consumption */
 	rt2800_bbp_read(rt2x00dev, 138, &reg);
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
 	if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH) == 1)
 		rt2x00_set_field8(&reg, BBP138_RX_ADC1, 0);
 	if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_TXPATH) == 1)
@@ -4884,7 +4906,8 @@ static void rt2800_init_rfcsr_30xx(struct rt2x00_dev *rt2x00dev)
 		rt2x00_set_field32(&reg, LDO_CFG0_BGSEL, 1);
 		if (rt2x00_rt_rev_lt(rt2x00dev, RT3071, REV_RT3071E) ||
 		    rt2x00_rt_rev_lt(rt2x00dev, RT3090, REV_RT3090E)) {
-			rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
+			rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1,
+					   &eeprom);
 			if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_DAC_TEST))
 				rt2x00_set_field32(&reg, LDO_CFG0_LDO_CORE_VLEVEL, 3);
 			else
@@ -5456,15 +5479,15 @@ int rt2800_enable_radio(struct rt2x00_dev *rt2x00dev)
 	/*
 	 * Initialize LED control
 	 */
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_LED_AG_CONF, &word);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_LED_AG_CONF, &word);
 	rt2800_mcu_request(rt2x00dev, MCU_LED_AG_CONF, 0xff,
 			   word & 0xff, (word >> 8) & 0xff);
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_LED_ACT_CONF, &word);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_LED_ACT_CONF, &word);
 	rt2800_mcu_request(rt2x00dev, MCU_LED_ACT_CONF, 0xff,
 			   word & 0xff, (word >> 8) & 0xff);
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_LED_POLARITY, &word);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_LED_POLARITY, &word);
 	rt2800_mcu_request(rt2x00dev, MCU_LED_LED_POLARITY, 0xff,
 			   word & 0xff, (word >> 8) & 0xff);
 
@@ -5578,18 +5601,18 @@ static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 	/*
 	 * Start validation of the data that has been read.
 	 */
-	mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
+	mac = rt2800_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
 	if (!is_valid_ether_addr(mac)) {
 		eth_random_addr(mac);
 		rt2x00_eeprom_dbg(rt2x00dev, "MAC: %pM\n", mac);
 	}
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &word);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &word);
 	if (word == 0xffff) {
 		rt2x00_set_field16(&word, EEPROM_NIC_CONF0_RXPATH, 2);
 		rt2x00_set_field16(&word, EEPROM_NIC_CONF0_TXPATH, 1);
 		rt2x00_set_field16(&word, EEPROM_NIC_CONF0_RF_TYPE, RF2820);
-		rt2x00_eeprom_write(rt2x00dev, EEPROM_NIC_CONF0, word);
+		rt2800_eeprom_write(rt2x00dev, EEPROM_NIC_CONF0, word);
 		rt2x00_eeprom_dbg(rt2x00dev, "Antenna: 0x%04x\n", word);
 	} else if (rt2x00_rt(rt2x00dev, RT2860) ||
 		   rt2x00_rt(rt2x00dev, RT2872)) {
@@ -5598,10 +5621,10 @@ static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 		 */
 		if (rt2x00_get_field16(word, EEPROM_NIC_CONF0_RXPATH) > 2)
 			rt2x00_set_field16(&word, EEPROM_NIC_CONF0_RXPATH, 2);
-		rt2x00_eeprom_write(rt2x00dev, EEPROM_NIC_CONF0, word);
+		rt2800_eeprom_write(rt2x00dev, EEPROM_NIC_CONF0, word);
 	}
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &word);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &word);
 	if (word == 0xffff) {
 		rt2x00_set_field16(&word, EEPROM_NIC_CONF1_HW_RADIO, 0);
 		rt2x00_set_field16(&word, EEPROM_NIC_CONF1_EXTERNAL_TX_ALC, 0);
@@ -5618,24 +5641,24 @@ static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 		rt2x00_set_field16(&word, EEPROM_NIC_CONF1_INTERNAL_TX_ALC, 0);
 		rt2x00_set_field16(&word, EEPROM_NIC_CONF1_BT_COEXIST, 0);
 		rt2x00_set_field16(&word, EEPROM_NIC_CONF1_DAC_TEST, 0);
-		rt2x00_eeprom_write(rt2x00dev, EEPROM_NIC_CONF1, word);
+		rt2800_eeprom_write(rt2x00dev, EEPROM_NIC_CONF1, word);
 		rt2x00_eeprom_dbg(rt2x00dev, "NIC: 0x%04x\n", word);
 	}
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &word);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_FREQ, &word);
 	if ((word & 0x00ff) == 0x00ff) {
 		rt2x00_set_field16(&word, EEPROM_FREQ_OFFSET, 0);
-		rt2x00_eeprom_write(rt2x00dev, EEPROM_FREQ, word);
+		rt2800_eeprom_write(rt2x00dev, EEPROM_FREQ, word);
 		rt2x00_eeprom_dbg(rt2x00dev, "Freq: 0x%04x\n", word);
 	}
 	if ((word & 0xff00) == 0xff00) {
 		rt2x00_set_field16(&word, EEPROM_FREQ_LED_MODE,
 				   LED_MODE_TXRX_ACTIVITY);
 		rt2x00_set_field16(&word, EEPROM_FREQ_LED_POLARITY, 0);
-		rt2x00_eeprom_write(rt2x00dev, EEPROM_FREQ, word);
-		rt2x00_eeprom_write(rt2x00dev, EEPROM_LED_AG_CONF, 0x5555);
-		rt2x00_eeprom_write(rt2x00dev, EEPROM_LED_ACT_CONF, 0x2221);
-		rt2x00_eeprom_write(rt2x00dev, EEPROM_LED_POLARITY, 0xa9f8);
+		rt2800_eeprom_write(rt2x00dev, EEPROM_FREQ, word);
+		rt2800_eeprom_write(rt2x00dev, EEPROM_LED_AG_CONF, 0x5555);
+		rt2800_eeprom_write(rt2x00dev, EEPROM_LED_ACT_CONF, 0x2221);
+		rt2800_eeprom_write(rt2x00dev, EEPROM_LED_POLARITY, 0xa9f8);
 		rt2x00_eeprom_dbg(rt2x00dev, "Led Mode: 0x%04x\n", word);
 	}
 
@@ -5644,17 +5667,17 @@ static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 	 * lna0 as correct value. Note that EEPROM_LNA
 	 * is never validated.
 	 */
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_LNA, &word);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_LNA, &word);
 	default_lna_gain = rt2x00_get_field16(word, EEPROM_LNA_A0);
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG, &word);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_BG, &word);
 	if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG_OFFSET0)) > 10)
 		rt2x00_set_field16(&word, EEPROM_RSSI_BG_OFFSET0, 0);
 	if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG_OFFSET1)) > 10)
 		rt2x00_set_field16(&word, EEPROM_RSSI_BG_OFFSET1, 0);
-	rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_BG, word);
+	rt2800_eeprom_write(rt2x00dev, EEPROM_RSSI_BG, word);
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_BG, &word);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_BG, &word);
 	if ((word & 0x00ff) != 0x00ff) {
 		drv_data->txmixer_gain_24g =
 			rt2x00_get_field16(word, EEPROM_TXMIXER_GAIN_BG_VAL);
@@ -5662,16 +5685,16 @@ static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 		drv_data->txmixer_gain_24g = 0;
 	}
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &word);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &word);
 	if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG2_OFFSET2)) > 10)
 		rt2x00_set_field16(&word, EEPROM_RSSI_BG2_OFFSET2, 0);
 	if (rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0x00 ||
 	    rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0xff)
 		rt2x00_set_field16(&word, EEPROM_RSSI_BG2_LNA_A1,
 				   default_lna_gain);
-	rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_BG2, word);
+	rt2800_eeprom_write(rt2x00dev, EEPROM_RSSI_BG2, word);
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_A, &word);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_A, &word);
 	if ((word & 0x00ff) != 0x00ff) {
 		drv_data->txmixer_gain_5g =
 			rt2x00_get_field16(word, EEPROM_TXMIXER_GAIN_A_VAL);
@@ -5679,21 +5702,21 @@ static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 		drv_data->txmixer_gain_5g = 0;
 	}
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A, &word);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_A, &word);
 	if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A_OFFSET0)) > 10)
 		rt2x00_set_field16(&word, EEPROM_RSSI_A_OFFSET0, 0);
 	if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A_OFFSET1)) > 10)
 		rt2x00_set_field16(&word, EEPROM_RSSI_A_OFFSET1, 0);
-	rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_A, word);
+	rt2800_eeprom_write(rt2x00dev, EEPROM_RSSI_A, word);
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &word);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &word);
 	if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A2_OFFSET2)) > 10)
 		rt2x00_set_field16(&word, EEPROM_RSSI_A2_OFFSET2, 0);
 	if (rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0x00 ||
 	    rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0xff)
 		rt2x00_set_field16(&word, EEPROM_RSSI_A2_LNA_A2,
 				   default_lna_gain);
-	rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_A2, word);
+	rt2800_eeprom_write(rt2x00dev, EEPROM_RSSI_A2, word);
 
 	return 0;
 }
@@ -5707,7 +5730,7 @@ static int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
 	/*
 	 * Read EEPROM word for configuration.
 	 */
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
 
 	/*
 	 * Identify RF chipset by EEPROM value
@@ -5717,7 +5740,7 @@ static int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
 	if (rt2x00_rt(rt2x00dev, RT3290) ||
 	    rt2x00_rt(rt2x00dev, RT5390) ||
 	    rt2x00_rt(rt2x00dev, RT5392))
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_CHIP_ID, &rf);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_CHIP_ID, &rf);
 	else
 		rf = rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RF_TYPE);
 
@@ -5757,7 +5780,7 @@ static int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
 	rt2x00dev->default_ant.rx_chain_num =
 	    rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH);
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
 
 	if (rt2x00_rt(rt2x00dev, RT3070) ||
 	    rt2x00_rt(rt2x00dev, RT3090) ||
@@ -5810,7 +5833,7 @@ static int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
 	/*
 	 * Read frequency offset and RF programming sequence.
 	 */
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &eeprom);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_FREQ, &eeprom);
 	rt2x00dev->freq_offset = rt2x00_get_field16(eeprom, EEPROM_FREQ_OFFSET);
 
 	/*
@@ -5827,7 +5850,7 @@ static int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
 	/*
 	 * Check if support EIRP tx power limit feature.
 	 */
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_EIRP_MAX_TX_POWER, &eeprom);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_EIRP_MAX_TX_POWER, &eeprom);
 
 	if (rt2x00_get_field16(eeprom, EEPROM_EIRP_MAX_TX_POWER_2GHZ) <
 					EIRP_MAX_TX_POWER_LIMIT)
@@ -6148,7 +6171,7 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
 
 	SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
 	SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
-				rt2x00_eeprom_addr(rt2x00dev,
+				rt2800_eeprom_addr(rt2x00dev,
 						   EEPROM_MAC_ADDR_0));
 
 	/*
@@ -6164,7 +6187,7 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
 	rt2x00dev->hw->max_report_rates = 7;
 	rt2x00dev->hw->max_rate_tries = 1;
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
 
 	/*
 	 * Initialize hw_mode information.
@@ -6264,8 +6287,8 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
 
 	spec->channels_info = info;
 
-	default_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG1);
-	default_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG2);
+	default_power1 = rt2800_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG1);
+	default_power2 = rt2800_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG2);
 
 	for (i = 0; i < 14; i++) {
 		info[i].default_power1 = default_power1[i];
@@ -6273,8 +6296,10 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
 	}
 
 	if (spec->num_channels > 14) {
-		default_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A1);
-		default_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A2);
+		default_power1 = rt2800_eeprom_addr(rt2x00dev,
+						    EEPROM_TXPOWER_A1);
+		default_power2 = rt2800_eeprom_addr(rt2x00dev,
+						    EEPROM_TXPOWER_A2);
 
 		for (i = 14; i < spec->num_channels; i++) {
 			info[i].default_power1 = default_power1[i - 14];
-- 
1.7.10


^ permalink raw reply related

* [PATCH v2 3/5] rt2x00: rt2800lib: introduce rt2800_eeprom_read_from_array helper
From: Gabor Juhos @ 2013-07-08  9:25 UTC (permalink / raw)
  To: John Linville; +Cc: linux-wireless, users, Gabor Juhos
In-Reply-To: <1373275556-6482-1-git-send-email-juhosg@openwrt.org>

Add a new helper function and use that for reading
single elements of various arrays in the EEPROM.

The patch does not change the current behaviour,
but it allows to use sequential values for the
rt2800_eeprom_word enums. The conversion will be
implemented in a subsequent change.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>
---
Changes since v1: ---
---
 drivers/net/wireless/rt2x00/rt2800lib.c |   23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 522f0b1..b59772a 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -239,6 +239,14 @@ static void rt2800_eeprom_write(struct rt2x00_dev *rt2x00dev,
 	rt2x00_eeprom_write(rt2x00dev, word, data);
 }
 
+static void rt2800_eeprom_read_from_array(struct rt2x00_dev *rt2x00dev,
+					  const enum rt2800_eeprom_word array,
+					  unsigned int offset,
+					  u16 *data)
+{
+	rt2x00_eeprom_read(rt2x00dev, array + offset, data);
+}
+
 static int rt2800_enable_wlan_rt3290(struct rt2x00_dev *rt2x00dev)
 {
 	u32 reg;
@@ -2995,8 +3003,8 @@ static u8 rt2800_compensate_txpower(struct rt2x00_dev *rt2x00dev, int is_rate_b,
 		 * .11b data rate need add additional 4dbm
 		 * when calculating eirp txpower.
 		 */
-		rt2800_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + 1,
-				   &eeprom);
+		rt2800_eeprom_read_from_array(rt2x00dev, EEPROM_TXPOWER_BYRATE,
+					      1, &eeprom);
 		criterion = rt2x00_get_field16(eeprom,
 					       EEPROM_TXPOWER_BYRATE_RATE0);
 
@@ -3101,8 +3109,8 @@ static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev,
 		rt2800_register_read(rt2x00dev, offset, &reg);
 
 		/* read the next four txpower values */
-		rt2800_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + i,
-				   &eeprom);
+		rt2800_eeprom_read_from_array(rt2x00dev, EEPROM_TXPOWER_BYRATE,
+					      i, &eeprom);
 
 		is_rate_b = i ? 0 : 1;
 		/*
@@ -3150,8 +3158,8 @@ static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev,
 		rt2x00_set_field32(&reg, TX_PWR_CFG_RATE3, txpower);
 
 		/* read the next four txpower values */
-		rt2800_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + i + 1,
-				   &eeprom);
+		rt2800_eeprom_read_from_array(rt2x00dev, EEPROM_TXPOWER_BYRATE,
+					      i + 1, &eeprom);
 
 		is_rate_b = 0;
 		/*
@@ -4579,7 +4587,8 @@ static void rt2800_init_bbp(struct rt2x00_dev *rt2x00dev)
 	}
 
 	for (i = 0; i < EEPROM_BBP_SIZE; i++) {
-		rt2800_eeprom_read(rt2x00dev, EEPROM_BBP_START + i, &eeprom);
+		rt2800_eeprom_read_from_array(rt2x00dev, EEPROM_BBP_START, i,
+					      &eeprom);
 
 		if (eeprom != 0xffff && eeprom != 0x0000) {
 			reg_id = rt2x00_get_field16(eeprom, EEPROM_BBP_REG_ID);
-- 
1.7.10


^ permalink raw reply related

* [PATCH v2 1/5] rt2x00: rt2800lib: introduce rt2800_eeprom_word enum
From: Gabor Juhos @ 2013-07-08  9:25 UTC (permalink / raw)
  To: John Linville; +Cc: linux-wireless, users, Gabor Juhos
In-Reply-To: <1373275556-6482-1-git-send-email-juhosg@openwrt.org>

The patch converts the EEPROM_* word address defines
into new enum values. The new enum type will be used
by new functions which will be introduced in subsequent
changes.

The patch contains no functional changes.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>
---
Changes since v1: ---
---
 drivers/net/wireless/rt2x00/rt2800.h |   79 +++++++++++++++++-----------------
 1 file changed, 39 insertions(+), 40 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h
index d78c495..0647039 100644
--- a/drivers/net/wireless/rt2x00/rt2800.h
+++ b/drivers/net/wireless/rt2x00/rt2800.h
@@ -2206,28 +2206,59 @@ struct mac_iveiv_entry {
  * The wordsize of the EEPROM is 16 bits.
  */
 
-/*
- * Chip ID
- */
-#define EEPROM_CHIP_ID			0x0000
+enum rt2800_eeprom_word {
+	EEPROM_CHIP_ID		= 0x0000,
+	EEPROM_VERSION		= 0x0001,
+	EEPROM_MAC_ADDR_0	= 0x0002,
+	EEPROM_MAC_ADDR_1	= 0x0003,
+	EEPROM_MAC_ADDR_2	= 0x0004,
+	EEPROM_NIC_CONF0	= 0x001a,
+	EEPROM_NIC_CONF1	= 0x001b,
+	EEPROM_FREQ		= 0x001d,
+	EEPROM_LED_AG_CONF	= 0x001e,
+	EEPROM_LED_ACT_CONF	= 0x001f,
+	EEPROM_LED_POLARITY	= 0x0020,
+	EEPROM_NIC_CONF2	= 0x0021,
+	EEPROM_LNA		= 0x0022,
+	EEPROM_RSSI_BG		= 0x0023,
+	EEPROM_RSSI_BG2		= 0x0024,
+	EEPROM_TXMIXER_GAIN_BG	= 0x0024, /* overlaps with RSSI_BG2 */
+	EEPROM_RSSI_A		= 0x0025,
+	EEPROM_RSSI_A2		= 0x0026,
+	EEPROM_TXMIXER_GAIN_A	= 0x0026, /* overlaps with RSSI_A2 */
+	EEPROM_EIRP_MAX_TX_POWER = 0x0027,
+	EEPROM_TXPOWER_DELTA	= 0x0028,
+	EEPROM_TXPOWER_BG1	= 0x0029,
+	EEPROM_TXPOWER_BG2	= 0x0030,
+	EEPROM_TSSI_BOUND_BG1	= 0x0037,
+	EEPROM_TSSI_BOUND_BG2	= 0x0038,
+	EEPROM_TSSI_BOUND_BG3	= 0x0039,
+	EEPROM_TSSI_BOUND_BG4	= 0x003a,
+	EEPROM_TSSI_BOUND_BG5	= 0x003b,
+	EEPROM_TXPOWER_A1	= 0x003c,
+	EEPROM_TXPOWER_A2	= 0x0053,
+	EEPROM_TSSI_BOUND_A1	= 0x006a,
+	EEPROM_TSSI_BOUND_A2	= 0x006b,
+	EEPROM_TSSI_BOUND_A3	= 0x006c,
+	EEPROM_TSSI_BOUND_A4	= 0x006d,
+	EEPROM_TSSI_BOUND_A5	= 0x006e,
+	EEPROM_TXPOWER_BYRATE	= 0x006f,
+	EEPROM_BBP_START	= 0x0078,
+};
 
 /*
  * EEPROM Version
  */
-#define EEPROM_VERSION			0x0001
 #define EEPROM_VERSION_FAE		FIELD16(0x00ff)
 #define EEPROM_VERSION_VERSION		FIELD16(0xff00)
 
 /*
  * HW MAC address.
  */
-#define EEPROM_MAC_ADDR_0		0x0002
 #define EEPROM_MAC_ADDR_BYTE0		FIELD16(0x00ff)
 #define EEPROM_MAC_ADDR_BYTE1		FIELD16(0xff00)
-#define EEPROM_MAC_ADDR_1		0x0003
 #define EEPROM_MAC_ADDR_BYTE2		FIELD16(0x00ff)
 #define EEPROM_MAC_ADDR_BYTE3		FIELD16(0xff00)
-#define EEPROM_MAC_ADDR_2		0x0004
 #define EEPROM_MAC_ADDR_BYTE4		FIELD16(0x00ff)
 #define EEPROM_MAC_ADDR_BYTE5		FIELD16(0xff00)
 
@@ -2237,7 +2268,6 @@ struct mac_iveiv_entry {
  * TXPATH: 1: 1T, 2: 2T, 3: 3T
  * RF_TYPE: RFIC type
  */
-#define	EEPROM_NIC_CONF0		0x001a
 #define EEPROM_NIC_CONF0_RXPATH		FIELD16(0x000f)
 #define EEPROM_NIC_CONF0_TXPATH		FIELD16(0x00f0)
 #define EEPROM_NIC_CONF0_RF_TYPE		FIELD16(0x0f00)
@@ -2261,7 +2291,6 @@ struct mac_iveiv_entry {
  * BT_COEXIST: 0: disable, 1: enable
  * DAC_TEST: 0: disable, 1: enable
  */
-#define	EEPROM_NIC_CONF1		0x001b
 #define EEPROM_NIC_CONF1_HW_RADIO		FIELD16(0x0001)
 #define EEPROM_NIC_CONF1_EXTERNAL_TX_ALC		FIELD16(0x0002)
 #define EEPROM_NIC_CONF1_EXTERNAL_LNA_2G		FIELD16(0x0004)
@@ -2281,7 +2310,6 @@ struct mac_iveiv_entry {
 /*
  * EEPROM frequency
  */
-#define	EEPROM_FREQ			0x001d
 #define EEPROM_FREQ_OFFSET		FIELD16(0x00ff)
 #define EEPROM_FREQ_LED_MODE		FIELD16(0x7f00)
 #define EEPROM_FREQ_LED_POLARITY	FIELD16(0x1000)
@@ -2298,9 +2326,6 @@ struct mac_iveiv_entry {
  * POLARITY_GPIO_4: Polarity GPIO4 setting.
  * LED_MODE: Led mode.
  */
-#define EEPROM_LED_AG_CONF		0x001e
-#define EEPROM_LED_ACT_CONF		0x001f
-#define EEPROM_LED_POLARITY		0x0020
 #define EEPROM_LED_POLARITY_RDY_BG	FIELD16(0x0001)
 #define EEPROM_LED_POLARITY_RDY_A	FIELD16(0x0002)
 #define EEPROM_LED_POLARITY_ACT		FIELD16(0x0004)
@@ -2317,7 +2342,6 @@ struct mac_iveiv_entry {
  * TX_STREAM: 0: Reserved, 1: 1 Stream, 2: 2 Stream
  * CRYSTAL: 00: Reserved, 01: One crystal, 10: Two crystal, 11: Reserved
  */
-#define EEPROM_NIC_CONF2		0x0021
 #define EEPROM_NIC_CONF2_RX_STREAM		FIELD16(0x000f)
 #define EEPROM_NIC_CONF2_TX_STREAM		FIELD16(0x00f0)
 #define EEPROM_NIC_CONF2_CRYSTAL		FIELD16(0x0600)
@@ -2325,54 +2349,46 @@ struct mac_iveiv_entry {
 /*
  * EEPROM LNA
  */
-#define EEPROM_LNA			0x0022
 #define EEPROM_LNA_BG			FIELD16(0x00ff)
 #define EEPROM_LNA_A0			FIELD16(0xff00)
 
 /*
  * EEPROM RSSI BG offset
  */
-#define EEPROM_RSSI_BG			0x0023
 #define EEPROM_RSSI_BG_OFFSET0		FIELD16(0x00ff)
 #define EEPROM_RSSI_BG_OFFSET1		FIELD16(0xff00)
 
 /*
  * EEPROM RSSI BG2 offset
  */
-#define EEPROM_RSSI_BG2			0x0024
 #define EEPROM_RSSI_BG2_OFFSET2		FIELD16(0x00ff)
 #define EEPROM_RSSI_BG2_LNA_A1		FIELD16(0xff00)
 
 /*
  * EEPROM TXMIXER GAIN BG offset (note overlaps with EEPROM RSSI BG2).
  */
-#define EEPROM_TXMIXER_GAIN_BG		0x0024
 #define EEPROM_TXMIXER_GAIN_BG_VAL	FIELD16(0x0007)
 
 /*
  * EEPROM RSSI A offset
  */
-#define EEPROM_RSSI_A			0x0025
 #define EEPROM_RSSI_A_OFFSET0		FIELD16(0x00ff)
 #define EEPROM_RSSI_A_OFFSET1		FIELD16(0xff00)
 
 /*
  * EEPROM RSSI A2 offset
  */
-#define EEPROM_RSSI_A2			0x0026
 #define EEPROM_RSSI_A2_OFFSET2		FIELD16(0x00ff)
 #define EEPROM_RSSI_A2_LNA_A2		FIELD16(0xff00)
 
 /*
  * EEPROM TXMIXER GAIN A offset (note overlaps with EEPROM RSSI A2).
  */
-#define EEPROM_TXMIXER_GAIN_A		0x0026
 #define EEPROM_TXMIXER_GAIN_A_VAL	FIELD16(0x0007)
 
 /*
  * EEPROM EIRP Maximum TX power values(unit: dbm)
  */
-#define EEPROM_EIRP_MAX_TX_POWER	0x0027
 #define EEPROM_EIRP_MAX_TX_POWER_2GHZ	FIELD16(0x00ff)
 #define EEPROM_EIRP_MAX_TX_POWER_5GHZ	FIELD16(0xff00)
 
@@ -2383,7 +2399,6 @@ struct mac_iveiv_entry {
  * TYPE: 1: Plus the delta value, 0: minus the delta value
  * ENABLE: enable tx power compensation for 40BW
  */
-#define EEPROM_TXPOWER_DELTA		0x0028
 #define EEPROM_TXPOWER_DELTA_VALUE_2G	FIELD16(0x003f)
 #define EEPROM_TXPOWER_DELTA_TYPE_2G	FIELD16(0x0040)
 #define EEPROM_TXPOWER_DELTA_ENABLE_2G	FIELD16(0x0080)
@@ -2394,8 +2409,6 @@ struct mac_iveiv_entry {
 /*
  * EEPROM TXPOWER 802.11BG
  */
-#define	EEPROM_TXPOWER_BG1		0x0029
-#define	EEPROM_TXPOWER_BG2		0x0030
 #define EEPROM_TXPOWER_BG_SIZE		7
 #define EEPROM_TXPOWER_BG_1		FIELD16(0x00ff)
 #define EEPROM_TXPOWER_BG_2		FIELD16(0xff00)
@@ -2407,7 +2420,6 @@ struct mac_iveiv_entry {
  * MINUS3: If the actual TSSI is below this boundary, tx power needs to be
  *         reduced by (agc_step * -3)
  */
-#define EEPROM_TSSI_BOUND_BG1		0x0037
 #define EEPROM_TSSI_BOUND_BG1_MINUS4	FIELD16(0x00ff)
 #define EEPROM_TSSI_BOUND_BG1_MINUS3	FIELD16(0xff00)
 
@@ -2418,7 +2430,6 @@ struct mac_iveiv_entry {
  * MINUS1: If the actual TSSI is below this boundary, tx power needs to be
  *         reduced by (agc_step * -1)
  */
-#define EEPROM_TSSI_BOUND_BG2		0x0038
 #define EEPROM_TSSI_BOUND_BG2_MINUS2	FIELD16(0x00ff)
 #define EEPROM_TSSI_BOUND_BG2_MINUS1	FIELD16(0xff00)
 
@@ -2428,7 +2439,6 @@ struct mac_iveiv_entry {
  * PLUS1: If the actual TSSI is above this boundary, tx power needs to be
  *        increased by (agc_step * 1)
  */
-#define EEPROM_TSSI_BOUND_BG3		0x0039
 #define EEPROM_TSSI_BOUND_BG3_REF	FIELD16(0x00ff)
 #define EEPROM_TSSI_BOUND_BG3_PLUS1	FIELD16(0xff00)
 
@@ -2439,7 +2449,6 @@ struct mac_iveiv_entry {
  * PLUS3: If the actual TSSI is above this boundary, tx power needs to be
  *        increased by (agc_step * 3)
  */
-#define EEPROM_TSSI_BOUND_BG4		0x003a
 #define EEPROM_TSSI_BOUND_BG4_PLUS2	FIELD16(0x00ff)
 #define EEPROM_TSSI_BOUND_BG4_PLUS3	FIELD16(0xff00)
 
@@ -2449,15 +2458,12 @@ struct mac_iveiv_entry {
  *        increased by (agc_step * 4)
  * AGC_STEP: Temperature compensation step.
  */
-#define EEPROM_TSSI_BOUND_BG5		0x003b
 #define EEPROM_TSSI_BOUND_BG5_PLUS4	FIELD16(0x00ff)
 #define EEPROM_TSSI_BOUND_BG5_AGC_STEP	FIELD16(0xff00)
 
 /*
  * EEPROM TXPOWER 802.11A
  */
-#define EEPROM_TXPOWER_A1		0x003c
-#define EEPROM_TXPOWER_A2		0x0053
 #define EEPROM_TXPOWER_A_SIZE		6
 #define EEPROM_TXPOWER_A_1		FIELD16(0x00ff)
 #define EEPROM_TXPOWER_A_2		FIELD16(0xff00)
@@ -2469,7 +2475,6 @@ struct mac_iveiv_entry {
  * MINUS3: If the actual TSSI is below this boundary, tx power needs to be
  *         reduced by (agc_step * -3)
  */
-#define EEPROM_TSSI_BOUND_A1		0x006a
 #define EEPROM_TSSI_BOUND_A1_MINUS4	FIELD16(0x00ff)
 #define EEPROM_TSSI_BOUND_A1_MINUS3	FIELD16(0xff00)
 
@@ -2480,7 +2485,6 @@ struct mac_iveiv_entry {
  * MINUS1: If the actual TSSI is below this boundary, tx power needs to be
  *         reduced by (agc_step * -1)
  */
-#define EEPROM_TSSI_BOUND_A2		0x006b
 #define EEPROM_TSSI_BOUND_A2_MINUS2	FIELD16(0x00ff)
 #define EEPROM_TSSI_BOUND_A2_MINUS1	FIELD16(0xff00)
 
@@ -2490,7 +2494,6 @@ struct mac_iveiv_entry {
  * PLUS1: If the actual TSSI is above this boundary, tx power needs to be
  *        increased by (agc_step * 1)
  */
-#define EEPROM_TSSI_BOUND_A3		0x006c
 #define EEPROM_TSSI_BOUND_A3_REF	FIELD16(0x00ff)
 #define EEPROM_TSSI_BOUND_A3_PLUS1	FIELD16(0xff00)
 
@@ -2501,7 +2504,6 @@ struct mac_iveiv_entry {
  * PLUS3: If the actual TSSI is above this boundary, tx power needs to be
  *        increased by (agc_step * 3)
  */
-#define EEPROM_TSSI_BOUND_A4		0x006d
 #define EEPROM_TSSI_BOUND_A4_PLUS2	FIELD16(0x00ff)
 #define EEPROM_TSSI_BOUND_A4_PLUS3	FIELD16(0xff00)
 
@@ -2511,14 +2513,12 @@ struct mac_iveiv_entry {
  *        increased by (agc_step * 4)
  * AGC_STEP: Temperature compensation step.
  */
-#define EEPROM_TSSI_BOUND_A5		0x006e
 #define EEPROM_TSSI_BOUND_A5_PLUS4	FIELD16(0x00ff)
 #define EEPROM_TSSI_BOUND_A5_AGC_STEP	FIELD16(0xff00)
 
 /*
  * EEPROM TXPOWER by rate: tx power per tx rate for HT20 mode
  */
-#define EEPROM_TXPOWER_BYRATE		0x006f
 #define EEPROM_TXPOWER_BYRATE_SIZE	9
 
 #define EEPROM_TXPOWER_BYRATE_RATE0	FIELD16(0x000f)
@@ -2529,7 +2529,6 @@ struct mac_iveiv_entry {
 /*
  * EEPROM BBP.
  */
-#define	EEPROM_BBP_START		0x0078
 #define EEPROM_BBP_SIZE			16
 #define EEPROM_BBP_VALUE		FIELD16(0x00ff)
 #define EEPROM_BBP_REG_ID		FIELD16(0xff00)
-- 
1.7.10


^ permalink raw reply related

* [PATCH v2 0/5] rt2800lib: add support for extended EEPROM of three-cain devices
From: Gabor Juhos @ 2013-07-08  9:25 UTC (permalink / raw)
  To: John Linville; +Cc: linux-wireless, users, Gabor Juhos

Gabor Juhos (5):
  rt2x00: rt2800lib: introduce rt2800_eeprom_word enum
  rt2x00: rt2800lib: introduce local EEPROM access functions
  rt2x00: rt2800lib: introduce rt2800_eeprom_read_from_array helper
  rt2x00: rt2800lib: introduce rt2800_eeprom_word_index helper
  rt2x00: rt2800lib: add EEPROM map for the RT3593 chipset

 drivers/net/wireless/rt2x00/rt2800.h    |   87 +++++----
 drivers/net/wireless/rt2x00/rt2800lib.c |  305 +++++++++++++++++++++++--------
 2 files changed, 279 insertions(+), 113 deletions(-)

--
1.7.10


^ permalink raw reply

* Re: [PATCH] mac80211: add per-chain signal information to radiotap
From: Johannes Berg @ 2013-07-08  8:56 UTC (permalink / raw)
  To: linux-wireless
In-Reply-To: <1372851242-25474-1-git-send-email-johannes@sipsolutions.net>

On Wed, 2013-07-03 at 13:34 +0200, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@intel.com>
> 
> When per-chain signal information is available, don't add
> the antenna field once but instead add a radiotap namespace
> for each chain containing the chain/antenna number and the
> signal strength on that chain.

Applied.

johannes


^ permalink raw reply

* Re: [PATCH V2] vlan priority handling in WMM
From: Johannes Berg @ 2013-07-08  8:51 UTC (permalink / raw)
  To: voncken; +Cc: linux-wireless
In-Reply-To: <002b01ce798d$865cee70$9316cb50$@acksys.fr>

On Fri, 2013-07-05 at 16:39 +0200, voncken wrote:
> > >+	vlan_priority = (skb->vlan_tci & VLAN_PRIO_MASK) >>
> VLAN_PRIO_SHIFT;
> > >+	if (vlan_priority > 0)
> >> +		return vlan_priority;
> 
> > Is this really correct? For once, checking vlan_priority for
> non-zero seems
> > weird since that ought to be a valid value -- is there no other way
> to
> > determine that the value is valid?

> The vlan Tag contain three bit for priority. The value 0 indicate no
> priority (on this case the VLAN tag contain only VID). The vlan_tci
> field is set to zero if the frame do not contain the vlan tag. So if
> we have not a vlan tag or no priority in VLAN tag the priority value
> is always 0. 

Yes but don't we know that the vlan_tci field is valid?

I don't think you're correct in that 0 means "no priority present", it
actually means "best effort" as far as I can tell. Ignoring the VLAN tag
when the field is 0 would mean we could use a higher priority from the
contents of the frame, which would not be desired?

> >Also, this gives you a 2-bit value, while the return value should be
> a 3-bit value, maybe you need to shift this up by one to spread into
> the correct buckets?
> Sorry but I don't understand. The vlan_tci field it is a __u16 value
> (defined in include/linux/skbuff.h), the VLAN_PRIO_MASK is set to
> 0xE000 and VLAN_PRIO_SHIFT is set to 13 (defined in
> include/linux/if_vlan.h), the vlan_priority is an unsigned char. For
> me the vlan_priority contain a 3-bit value (0xE000 >>13 = 0x0003), why
> 2 ?

Umm? No? Think again about what hweight(0x0003) is.

johannes



^ permalink raw reply

* [PATCH] mac80211: fix ethtool stats for non-station interfaces
From: Johannes Berg @ 2013-07-08  8:46 UTC (permalink / raw)
  To: linux-wireless; +Cc: greearb

As reported in https://bugzilla.kernel.org/show_bug.cgi?id=60514,
the station loop never initialises 'sinfo' and therefore adds up
a stack values, leaking stack information (the number of times it
adds values is easily obtained another way.)

Fix this by initialising the sinfo for each station to add.

Cc: stable@vger.kernel.org
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
 net/mac80211/cfg.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 8184d12..43dd752 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -666,6 +666,8 @@ static void ieee80211_get_et_stats(struct wiphy *wiphy,
 			if (sta->sdata->dev != dev)
 				continue;
 
+			sinfo.filled = 0;
+			sta_set_sinfo(sta, &sinfo);
 			i = 0;
 			ADD_STA_STATS(sta);
 		}
-- 
1.8.0


^ permalink raw reply related

* Re: [PATCH] rtlwifi: Fix Kconfig for some corner cases
From: Larry Finger @ 2013-07-07 18:13 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: linville, linux-wireless, netdev, Fengguang Wu
In-Reply-To: <1373190151.3428.13.camel@deadeye.wl.decadent.org.uk>

On 07/07/2013 04:42 AM, Ben Hutchings wrote:
> On Sat, 2013-07-06 at 21:47 -0500, Larry Finger wrote:
>>
>> Although I could not duplicate this result on my machine, it seemed likely
>> that it was due to the unusual configuration where rtlwifi was being built,
>> but none of its dependent drivers were selected.
>
> I think it just requires:
>
> CONFIG_USB=m
> CONFIG_RTLWIFI=y
>
>> The fix is to select rtlwifi only when it is needed.
>
> I don't think so.  Consider this configuration:
>
> CONFIG_PCI=y
> CONFIG_USB=m
> CONFIG_RTL_CARDS=y
> CONFIG_RTL8192CE=y
> CONFIG_RTL8192CU=m
> CONFIG_RTLWIFI=y     # maximum of RTL8192CE=y and RTL8192CU=m
>
> The same breakage occurs.

Ben,

Thanks for your comments. I certainly do not claim to understand very much about 
the whole Kbuild process.

After setting up the above configuration manually, I ran 'make oldconfig' and 
got back

CONFIG_RTL_CARDS=m
CONFIG_RTL8192CE=m
CONFIG_RTL8192SE=m
CONFIG_RTL8192DE=m
CONFIG_RTL8723AE=m
CONFIG_RTL8188EE=m
CONFIG_RTL8192CU=m
CONFIG_RTLWIFI=m
CONFIG_RTLWIFI_DEBUG=y
CONFIG_RTL8192C_COMMON=m

That set of configuration parameters built normally.

>> While making this
>> change, I simplified the configuration so that variable RTLWIFI is never seen
>> by the user.
> [...]
>
> This will break existing configurations as RTL_CARDS defaults to n.

I added a 'default y' to the RTL_CARDS stanza. I now get the following:

finger@larrylap:~/staging> make
scripts/kconfig/conf --silentoldconfig Kconfig
*
* Restart config...
*
*
* Realtek rtlwifi family of devices
*
Realtek rtlwifi family of devices (RTL_CARDS) [M/n/?] (NEW)

That should prevent breakage of existing configurations. It defaults to "m" 
because mac80211 is built as a module in my configuration.

> Perhaps you should introduce separate modules for the common PCI and USB
> support code, similarly to how the rt2x00 modules are organised.

That would not be very difficult, but it would involve converting the single 
module rtlwifi into 3 separate entities. Does that make sense to you? I'm not sure.

Thanks again for your comments.

Larry




^ permalink raw reply

* RE: [PATCH] mwifiex: don't ignore SDIO interrupts during shutdown
From: Amitkumar Karwar @ 2013-07-07 16:15 UTC (permalink / raw)
  To: 'Daniel Drake'
  Cc: Bing Zhao, 'linux-wireless@vger.kernel.org',
	'linville@tuxdriver.com'
In-Reply-To: <5FF020A1CFFEEC49BD1E09530C4FF5951035636354@SC-VEXCH1.marvell.com>

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


Hi Daniel,

>We didn't test the behavior of sdio_read/sdio_write API's when hardware is >not present. But they should just return an error.

I ran some tests which confirmed that there is no harm in calling these API's when hardware is removed. They returned ENOMEDIUM error.

Can you please review and verify attached patch?

Thanks,
Amitkumar Karwar

[-- Attachment #2: 0001-mwifiex-disable-SDIO-interrupts-in-remove-handler.patch --]
[-- Type: application/octet-stream, Size: 5178 bytes --]

From d1b063d2097d30fd445b31a985c024765a9c14e1 Mon Sep 17 00:00:00 2001
From: Amitkumar Karwar <akarwar@marvell.com>
Date: Mon, 8 Jul 2013 21:16:08 +0530
Subject: [PATCH] mwifiex: disable SDIO interrupts in remove handler

Our mwifiex_sdio_remove() handler sets surprised_removed
flag. This causes SDIO_interrupt handler to ignore all
further interrupts without acking them. This may lead to
an interrupt storm causing problem for bluetooth driver
which operates same wifi card.

The problem is fixed by disabling interrupts in remove
handler. If there is an interrupt in process, the logic
to wait until it gets completed is already there
(mwifiex_shutdown_drv() call).
Some code is moved in this patch to prevent forward
declarations.

Inspired by a patch sent by Daniel Drake <dsd@laptop.org>

Reported-by: Daniel Drake <dsd@laptop.org>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
---
 drivers/net/wireless/mwifiex/sdio.c |  121 +++++++++++++++++------------------
 1 files changed, 58 insertions(+), 63 deletions(-)

diff --git a/drivers/net/wireless/mwifiex/sdio.c b/drivers/net/wireless/mwifiex/sdio.c
index 14ac51f..f79800b 100644
--- a/drivers/net/wireless/mwifiex/sdio.c
+++ b/drivers/net/wireless/mwifiex/sdio.c
@@ -111,6 +111,61 @@ mwifiex_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id)
 	return ret;
 }
 
+/* This function reads data from SDIO card register. */
+static int
+mwifiex_read_reg(struct mwifiex_adapter *adapter, u32 reg, u8 *data)
+{
+	struct sdio_mmc_card *card = adapter->card;
+	int ret = -1;
+	u8 val;
+
+	sdio_claim_host(card->func);
+	val = sdio_readb(card->func, reg, &ret);
+	sdio_release_host(card->func);
+
+	*data = val;
+
+	return ret;
+}
+
+/* This function writes data into SDIO card register. */
+static int
+mwifiex_write_reg(struct mwifiex_adapter *adapter, u32 reg, u8 data)
+{
+	struct sdio_mmc_card *card = adapter->card;
+	int ret = -1;
+
+	sdio_claim_host(card->func);
+	sdio_writeb(card->func, data, reg, &ret);
+	sdio_release_host(card->func);
+
+	return ret;
+}
+
+/* This function disables the host interrupt.
+ *
+ * The host interrupt mask is read, the disable bit is reset and
+ * written back to the card host interrupt mask register.
+ */
+static int mwifiex_sdio_disable_host_int(struct mwifiex_adapter *adapter)
+{
+	u8 host_int_mask, host_int_disable = HOST_INT_DISABLE;
+
+	/* Read back the host_int_mask register */
+	if (mwifiex_read_reg(adapter, HOST_INT_MASK_REG, &host_int_mask))
+		return -1;
+
+	/* Update with the mask and write back to the register */
+	host_int_mask &= ~host_int_disable;
+
+	if (mwifiex_write_reg(adapter, HOST_INT_MASK_REG, host_int_mask)) {
+		dev_err(adapter->dev, "disable host interrupt failed\n");
+		return -1;
+	}
+
+	return 0;
+}
+
 /*
  * SDIO remove.
  *
@@ -152,6 +207,9 @@ mwifiex_sdio_remove(struct sdio_func *func)
 		mwifiex_init_shutdown_fw(priv, MWIFIEX_FUNC_SHUTDOWN);
 	}
 
+	/* Disable host interrupt mask register for SDIO */
+	mwifiex_sdio_disable_host_int(adapter);
+
 	mwifiex_remove_card(card->adapter, &add_remove_card_sem);
 	kfree(card);
 }
@@ -297,41 +355,6 @@ static struct sdio_driver mwifiex_sdio = {
 };
 
 /*
- * This function writes data into SDIO card register.
- */
-static int
-mwifiex_write_reg(struct mwifiex_adapter *adapter, u32 reg, u8 data)
-{
-	struct sdio_mmc_card *card = adapter->card;
-	int ret = -1;
-
-	sdio_claim_host(card->func);
-	sdio_writeb(card->func, data, reg, &ret);
-	sdio_release_host(card->func);
-
-	return ret;
-}
-
-/*
- * This function reads data from SDIO card register.
- */
-static int
-mwifiex_read_reg(struct mwifiex_adapter *adapter, u32 reg, u8 *data)
-{
-	struct sdio_mmc_card *card = adapter->card;
-	int ret = -1;
-	u8 val;
-
-	sdio_claim_host(card->func);
-	val = sdio_readb(card->func, reg, &ret);
-	sdio_release_host(card->func);
-
-	*data = val;
-
-	return ret;
-}
-
-/*
  * This function writes multiple data into SDIO card memory.
  *
  * This does not work in suspended mode.
@@ -680,31 +703,6 @@ mwifiex_sdio_read_fw_status(struct mwifiex_adapter *adapter, u16 *dat)
 }
 
 /*
- * This function disables the host interrupt.
- *
- * The host interrupt mask is read, the disable bit is reset and
- * written back to the card host interrupt mask register.
- */
-static int mwifiex_sdio_disable_host_int(struct mwifiex_adapter *adapter)
-{
-	u8 host_int_mask, host_int_disable = HOST_INT_DISABLE;
-
-	/* Read back the host_int_mask register */
-	if (mwifiex_read_reg(adapter, HOST_INT_MASK_REG, &host_int_mask))
-		return -1;
-
-	/* Update with the mask and write back to the register */
-	host_int_mask &= ~host_int_disable;
-
-	if (mwifiex_write_reg(adapter, HOST_INT_MASK_REG, host_int_mask)) {
-		dev_err(adapter->dev, "disable host interrupt failed\n");
-		return -1;
-	}
-
-	return 0;
-}
-
-/*
  * This function enables the host interrupt.
  *
  * The host interrupt enable mask is written to the card
@@ -997,9 +995,6 @@ mwifiex_sdio_interrupt(struct sdio_func *func)
 	}
 	adapter = card->adapter;
 
-	if (adapter->surprise_removed)
-		return;
-
 	if (!adapter->pps_uapsd_mode && adapter->ps_state == PS_STATE_SLEEP)
 		adapter->ps_state = PS_STATE_AWAKE;
 
-- 
1.7.3.4


^ permalink raw reply related

* Re: [rt2x00-users] [PATCH v2 00/20] rt2x00: add experimental support for RT3593
From: Stanislaw Gruszka @ 2013-07-07 14:42 UTC (permalink / raw)
  To: Gabor Juhos; +Cc: John Linville, linux-wireless, users
In-Reply-To: <1372664879-18474-1-git-send-email-juhosg@openwrt.org>

On Mon, Jul 01, 2013 at 09:47:39AM +0200, Gabor Juhos wrote:
> This patch-set implements experiemental support for the
> RT3593 chipset. The patches are tested on the Linksys
> AE3000 USB device only, however other USB devices which
> are using the RT3573 chips might work as well.

Good work Gabor!

Thanks
Stanislaw

^ permalink raw reply

* Re: [rt2x00-users] [PATCH v2 20/20] rt2x00: rt2800usb: add USB device ID for Linksys AE3000
From: Stanislaw Gruszka @ 2013-07-07 14:41 UTC (permalink / raw)
  To: Gabor Juhos; +Cc: John Linville, linux-wireless, users
In-Reply-To: <1372664879-18474-21-git-send-email-juhosg@openwrt.org>

On Mon, Jul 01, 2013 at 09:47:59AM +0200, Gabor Juhos wrote:
> The Linksys AE3000 device is based on the RT3573
> chipset. The support for this chipset is available
> already, and the AE3000 device works with the driver.
> 
> Only managed mode works correctly at the moment,
> for AP mode additional changes are needed in the
> driver.
> 
> Also add a new RT2800USB_RT3573 Kconfig option and
> only enable support for RT3573 based devices if
> that is enabled.
> 
> Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>

^ permalink raw reply

* Re: [rt2x00-users] [PATCH v2 19/20] rt2x00: rt2800usb: use correct [RT]XWI size for RT3593
From: Stanislaw Gruszka @ 2013-07-07 14:41 UTC (permalink / raw)
  To: Gabor Juhos; +Cc: John Linville, linux-wireless, users
In-Reply-To: <1372664879-18474-20-git-send-email-juhosg@openwrt.org>

On Mon, Jul 01, 2013 at 09:47:58AM +0200, Gabor Juhos wrote:
> The RT3593 chipset requires different [RT]XWI size
> values. Modify the driver to use the correct values.
> 
> Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>


^ permalink raw reply

* Re: [rt2x00-users] [PATCH v2 18/20] rt2x00: rt2800lib: enable RT3593 support
From: Stanislaw Gruszka @ 2013-07-07 14:40 UTC (permalink / raw)
  To: Gabor Juhos; +Cc: John Linville, linux-wireless, users
In-Reply-To: <1372664879-18474-19-git-send-email-juhosg@openwrt.org>

On Mon, Jul 01, 2013 at 09:47:57AM +0200, Gabor Juhos wrote:
> Support for the RT3593 has been implemented in
> the previous changes, so it is safe to mark it
> supported in the driver.
> 
> Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>

^ permalink raw reply

* Re: [rt2x00-users] [PATCH v2 17/20] rt2x00: rt2800lib: enable RF3053 support
From: Stanislaw Gruszka @ 2013-07-07 14:40 UTC (permalink / raw)
  To: Gabor Juhos; +Cc: John Linville, linux-wireless, users
In-Reply-To: <1372664879-18474-18-git-send-email-juhosg@openwrt.org>

On Mon, Jul 01, 2013 at 09:47:56AM +0200, Gabor Juhos wrote:
> Support for the RF3053 has been implemented in
> the previous changes, so it is safe to mark it
> supported in the driver.
> 
> Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox