From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
To: linux-wireless@vger.kernel.org
Cc: Gertjan van Wingerde <gwingerde@gmail.com>,
Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>,
Ivo van Doorn <ivdoorn@gmail.com>
Subject: [PATCH 1/9] rt2800: prepare for unification of EEPROM support code
Date: Sun, 08 Nov 2009 14:38:54 +0100 [thread overview]
Message-ID: <20091108133854.23584.86842.sendpatchset@localhost.localdomain> (raw)
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] rt2800: prepare for unification of EEPROM support code
* Factor out common code from rt2800[pci,usb]_validate_eeprom()
to rt2800_validate_eeprom().
* Fix interface specific comment in rt2800[pci,usb]_validate_eeprom().
* Enclose interface specific code in rt2800[pci,usb]_init_eeprom()
with rt2x00_intf_is_[pci,usb]() checks.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
on top of "rt2x00: Add dynamic detection of eFuse EEPROM in rt2800pci."
patch from Gertjan
drivers/net/wireless/rt2x00/rt2800pci.c | 51 ++++++++++++++++++--------------
drivers/net/wireless/rt2x00/rt2800usb.c | 40 +++++++++++++++----------
2 files changed, 55 insertions(+), 36 deletions(-)
Index: b/drivers/net/wireless/rt2x00/rt2800pci.c
===================================================================
--- a/drivers/net/wireless/rt2x00/rt2800pci.c
+++ b/drivers/net/wireless/rt2x00/rt2800pci.c
@@ -1091,29 +1091,13 @@ static irqreturn_t rt2800pci_interrupt(i
/*
* Device probe functions.
*/
-static int rt2800pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
+static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
{
u16 word;
u8 *mac;
u8 default_lna_gain;
/*
- * Read EEPROM into buffer
- */
- switch(rt2x00dev->chip.rt) {
- case RT2880:
- case RT3052:
- rt2800pci_read_eeprom_soc(rt2x00dev);
- break;
- default:
- if (rt2800pci_efuse_detect(rt2x00dev))
- rt2800pci_read_eeprom_efuse(rt2x00dev);
- else
- rt2800pci_read_eeprom_pci(rt2x00dev);
- break;
- }
-
- /*
* Start validation of the data that has been read.
*/
mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
@@ -1131,7 +1115,7 @@ static int rt2800pci_validate_eeprom(str
EEPROM(rt2x00dev, "Antenna: 0x%04x\n", word);
} else if (rt2x00_rev(&rt2x00dev->chip) < RT2883_VERSION) {
/*
- * There is a max of 2 RX streams for RT2860 series
+ * There is a max of 2 RX streams for RT28x0 series
*/
if (rt2x00_get_field16(word, EEPROM_ANTENNA_RXPATH) > 2)
rt2x00_set_field16(&word, EEPROM_ANTENNA_RXPATH, 2);
@@ -1210,6 +1194,27 @@ static int rt2800pci_validate_eeprom(str
return 0;
}
+static int rt2800pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
+{
+ /*
+ * Read EEPROM into buffer
+ */
+ switch (rt2x00dev->chip.rt) {
+ case RT2880:
+ case RT3052:
+ rt2800pci_read_eeprom_soc(rt2x00dev);
+ break;
+ default:
+ if (rt2800pci_efuse_detect(rt2x00dev))
+ rt2800pci_read_eeprom_efuse(rt2x00dev);
+ else
+ rt2800pci_read_eeprom_pci(rt2x00dev);
+ break;
+ }
+
+ return rt2800_validate_eeprom(rt2x00dev);
+}
+
static int rt2800pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
{
u32 reg;
@@ -1226,7 +1231,9 @@ static int rt2800pci_init_eeprom(struct
*/
value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
rt2800_register_read(rt2x00dev, MAC_CSR0, ®);
- rt2x00_set_chip_rf(rt2x00dev, value, reg);
+
+ if (rt2x00_intf_is_pci(rt2x00dev))
+ rt2x00_set_chip_rf(rt2x00dev, value, reg);
if (!rt2x00_rf(&rt2x00dev->chip, RF2820) &&
!rt2x00_rf(&rt2x00dev->chip, RF2850) &&
@@ -1234,8 +1241,10 @@ static int rt2800pci_init_eeprom(struct
!rt2x00_rf(&rt2x00dev->chip, RF2750) &&
!rt2x00_rf(&rt2x00dev->chip, RF3020) &&
!rt2x00_rf(&rt2x00dev->chip, RF2020) &&
- !rt2x00_rf(&rt2x00dev->chip, RF3021) &&
- !rt2x00_rf(&rt2x00dev->chip, RF3022)) {
+ (rt2x00_intf_is_usb(rt2x00dev) ||
+ (rt2x00_intf_is_pci(rt2x00dev) &&
+ !rt2x00_rf(&rt2x00dev->chip, RF3021) &&
+ !rt2x00_rf(&rt2x00dev->chip, RF3022)))) {
ERROR(rt2x00dev, "Invalid RF chipset detected.\n");
return -ENODEV;
}
Index: b/drivers/net/wireless/rt2x00/rt2800usb.c
===================================================================
--- a/drivers/net/wireless/rt2x00/rt2800usb.c
+++ b/drivers/net/wireless/rt2x00/rt2800usb.c
@@ -665,14 +665,12 @@ static void rt2800usb_fill_rxdone(struct
/*
* Device probe functions.
*/
-static int rt2800usb_validate_eeprom(struct rt2x00_dev *rt2x00dev)
+static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
{
u16 word;
u8 *mac;
u8 default_lna_gain;
- rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom, EEPROM_SIZE);
-
/*
* Start validation of the data that has been read.
*/
@@ -691,7 +689,7 @@ static int rt2800usb_validate_eeprom(str
EEPROM(rt2x00dev, "Antenna: 0x%04x\n", word);
} else if (rt2x00_rev(&rt2x00dev->chip) < RT2883_VERSION) {
/*
- * There is a max of 2 RX streams for RT2870 series
+ * There is a max of 2 RX streams for RT28x0 series
*/
if (rt2x00_get_field16(word, EEPROM_ANTENNA_RXPATH) > 2)
rt2x00_set_field16(&word, EEPROM_ANTENNA_RXPATH, 2);
@@ -770,6 +768,13 @@ static int rt2800usb_validate_eeprom(str
return 0;
}
+static int rt2800usb_validate_eeprom(struct rt2x00_dev *rt2x00dev)
+{
+ rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom, EEPROM_SIZE);
+
+ return rt2800_validate_eeprom(rt2x00dev);
+}
+
static int rt2800usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
{
u32 reg;
@@ -786,18 +791,23 @@ static int rt2800usb_init_eeprom(struct
*/
value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
rt2800_register_read(rt2x00dev, MAC_CSR0, ®);
- rt2x00_set_chip(rt2x00dev, RT2870, value, reg);
- /*
- * The check for rt2860 is not a typo, some rt2870 hardware
- * identifies itself as rt2860 in the CSR register.
- */
- if (!rt2x00_check_rev(&rt2x00dev->chip, 0xfff00000, 0x28600000) &&
- !rt2x00_check_rev(&rt2x00dev->chip, 0xfff00000, 0x28700000) &&
- !rt2x00_check_rev(&rt2x00dev->chip, 0xfff00000, 0x28800000) &&
- !rt2x00_check_rev(&rt2x00dev->chip, 0xffff0000, 0x30700000)) {
- ERROR(rt2x00dev, "Invalid RT chipset detected.\n");
- return -ENODEV;
+ if (rt2x00_intf_is_usb(rt2x00dev)) {
+ struct rt2x00_chip *chip = &rt2x00dev->chip;
+
+ rt2x00_set_chip(rt2x00dev, RT2870, value, reg);
+
+ /*
+ * The check for rt2860 is not a typo, some rt2870 hardware
+ * identifies itself as rt2860 in the CSR register.
+ */
+ if (!rt2x00_check_rev(chip, 0xfff00000, 0x28600000) &&
+ !rt2x00_check_rev(chip, 0xfff00000, 0x28700000) &&
+ !rt2x00_check_rev(chip, 0xfff00000, 0x28800000) &&
+ !rt2x00_check_rev(chip, 0xffff0000, 0x30700000)) {
+ ERROR(rt2x00dev, "Invalid RT chipset detected.\n");
+ return -ENODEV;
+ }
}
if (!rt2x00_rf(&rt2x00dev->chip, RF2820) &&
next reply other threads:[~2009-11-08 13:39 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-08 13:38 Bartlomiej Zolnierkiewicz [this message]
2009-11-08 13:39 ` [PATCH 2/9] rt2800: unify EEPROM support code Bartlomiej Zolnierkiewicz
2009-11-08 13:51 ` Ivo van Doorn
2009-11-08 14:19 ` Gertjan van Wingerde
2009-11-08 13:39 ` [PATCH 3/9] rt2800pci: add missing RF values to rf_vals table Bartlomiej Zolnierkiewicz
2009-11-08 13:51 ` Ivo van Doorn
2009-11-08 14:20 ` Gertjan van Wingerde
2009-11-08 13:39 ` [PATCH 4/9] rt2800usb: reorganize code in rt2800usb_probe_hw_mode() Bartlomiej Zolnierkiewicz
2009-11-08 13:52 ` Ivo van Doorn
2009-11-08 14:20 ` Gertjan van Wingerde
2009-11-08 13:39 ` [PATCH 5/9] rt2800: prepare for rt2800*_probe_hw_mode() unification Bartlomiej Zolnierkiewicz
2009-11-08 13:53 ` Ivo van Doorn
2009-11-08 14:35 ` Gertjan van Wingerde
2009-11-08 17:48 ` Bartlomiej Zolnierkiewicz
2009-11-08 19:09 ` Gertjan van Wingerde
2009-11-08 13:39 ` [PATCH 6/9] rt2800: unify rt2800*_probe_hw_mode() Bartlomiej Zolnierkiewicz
2009-11-08 13:53 ` Ivo van Doorn
2009-11-08 14:36 ` Gertjan van Wingerde
2009-11-08 13:39 ` [PATCH 7/9] rt2800usb: fix RX descriptor naming Bartlomiej Zolnierkiewicz
2009-11-08 13:54 ` Ivo van Doorn
2009-11-08 14:37 ` Gertjan van Wingerde
2009-11-08 13:39 ` [PATCH 8/9] rt2800: add eFuse EEPROM support code to rt2800lib Bartlomiej Zolnierkiewicz
2009-11-08 13:55 ` Ivo van Doorn
2009-11-08 17:34 ` Bartlomiej Zolnierkiewicz
2009-11-08 18:08 ` Ivo van Doorn
2009-11-08 18:13 ` Bartlomiej Zolnierkiewicz
2009-11-08 18:27 ` Ivo van Doorn
2009-11-08 18:32 ` Bartlomiej Zolnierkiewicz
2009-11-08 18:40 ` Ivo van Doorn
2009-11-08 18:47 ` Bartlomiej Zolnierkiewicz
2009-11-08 19:14 ` Kalle Valo
2009-11-08 19:21 ` Bartlomiej Zolnierkiewicz
2009-11-08 19:35 ` Ivo van Doorn
2009-11-08 19:38 ` Bartlomiej Zolnierkiewicz
2009-11-08 19:25 ` Ivo van Doorn
2009-11-08 19:34 ` Bartlomiej Zolnierkiewicz
2009-11-08 14:38 ` Gertjan van Wingerde
2009-11-08 13:39 ` [PATCH 9/9] rt2800usb: add eFuse EEPROM support Bartlomiej Zolnierkiewicz
2009-11-08 13:56 ` Ivo van Doorn
2009-11-08 14:41 ` Gertjan van Wingerde
2009-11-08 13:50 ` [PATCH 1/9] rt2800: prepare for unification of EEPROM support code Ivo van Doorn
2009-11-08 14:16 ` Gertjan van Wingerde
2009-11-08 17:41 ` Bartlomiej Zolnierkiewicz
2009-11-08 19:07 ` Gertjan van Wingerde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20091108133854.23584.86842.sendpatchset@localhost.localdomain \
--to=bzolnier@gmail.com \
--cc=gwingerde@gmail.com \
--cc=ivdoorn@gmail.com \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).