]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/wireless/zd1211rw/zd_chip.c
[PATCH] zd1211rw: removed noisy debug messages
[linux-2.6-omap-h63xx.git] / drivers / net / wireless / zd1211rw / zd_chip.c
index 87ee3ee020fe11727c355bbae433fb07c5ee9ebe..7e3c0625129b9b206e3f549dd2a0c8e9bacbb443 100644 (file)
@@ -49,8 +49,9 @@ void zd_chip_clear(struct zd_chip *chip)
        ZD_MEMCLEAR(chip, sizeof(*chip));
 }
 
-static int scnprint_mac_oui(const u8 *addr, char *buffer, size_t size)
+static int scnprint_mac_oui(struct zd_chip *chip, char *buffer, size_t size)
 {
+       u8 *addr = zd_usb_to_netdev(&chip->usb)->dev_addr;
        return scnprintf(buffer, size, "%02x-%02x-%02x",
                         addr[0], addr[1], addr[2]);
 }
@@ -61,17 +62,18 @@ static int scnprint_id(struct zd_chip *chip, char *buffer, size_t size)
        int i = 0;
 
        i = scnprintf(buffer, size, "zd1211%s chip ",
-                     chip->is_zd1211b ? "b" : "");
+                     zd_chip_is_zd1211b(chip) ? "b" : "");
        i += zd_usb_scnprint_id(&chip->usb, buffer+i, size-i);
        i += scnprintf(buffer+i, size-i, " ");
-       i += scnprint_mac_oui(chip->e2p_mac, buffer+i, size-i);
+       i += scnprint_mac_oui(chip, buffer+i, size-i);
        i += scnprintf(buffer+i, size-i, " ");
        i += zd_rf_scnprint_id(&chip->rf, buffer+i, size-i);
-       i += scnprintf(buffer+i, size-i, " pa%1x %c%c%c%c", chip->pa_type,
+       i += scnprintf(buffer+i, size-i, " pa%1x %c%c%c%c%c", chip->pa_type,
                chip->patch_cck_gain ? 'g' : '-',
                chip->patch_cr157 ? '7' : '-',
                chip->patch_6m_band_edge ? '6' : '-',
-               chip->new_phy_layout ? 'N' : '-');
+               chip->new_phy_layout ? 'N' : '-',
+               chip->al2230s_bit ? 'S' : '-');
        return i;
 }
 
@@ -114,7 +116,7 @@ int zd_ioread32v_locked(struct zd_chip *chip, u32 *values, const zd_addr_t *addr
        /* Allocate a single memory block for values and addresses. */
        count16 = 2*count;
        a16 = (zd_addr_t *) kmalloc(count16 * (sizeof(zd_addr_t) + sizeof(u16)),
-                                  GFP_NOFS);
+                                  GFP_KERNEL);
        if (!a16) {
                dev_dbg_f(zd_chip_dev(chip),
                          "error ENOMEM in allocation of a16\n");
@@ -163,7 +165,7 @@ int _zd_iowrite32v_locked(struct zd_chip *chip, const struct zd_ioreq32 *ioreqs,
 
        /* Allocate a single memory block for values and addresses. */
        count16 = 2*count;
-       ioreqs16 = kmalloc(count16 * sizeof(struct zd_ioreq16), GFP_NOFS);
+       ioreqs16 = kmalloc(count16 * sizeof(struct zd_ioreq16), GFP_KERNEL);
        if (!ioreqs16) {
                r = -ENOMEM;
                dev_dbg_f(zd_chip_dev(chip),
@@ -365,64 +367,9 @@ error:
        return r;
 }
 
-static int _read_mac_addr(struct zd_chip *chip, u8 *mac_addr,
-                         const zd_addr_t *addr)
-{
-       int r;
-       u32 parts[2];
-
-       r = zd_ioread32v_locked(chip, parts, (const zd_addr_t *)addr, 2);
-       if (r) {
-               dev_dbg_f(zd_chip_dev(chip),
-                       "error: couldn't read e2p macs. Error number %d\n", r);
-               return r;
-       }
-
-       mac_addr[0] = parts[0];
-       mac_addr[1] = parts[0] >>  8;
-       mac_addr[2] = parts[0] >> 16;
-       mac_addr[3] = parts[0] >> 24;
-       mac_addr[4] = parts[1];
-       mac_addr[5] = parts[1] >>  8;
-
-       return 0;
-}
-
-static int read_e2p_mac_addr(struct zd_chip *chip)
-{
-       static const zd_addr_t addr[2] = { E2P_MAC_ADDR_P1, E2P_MAC_ADDR_P2 };
-
-       ZD_ASSERT(mutex_is_locked(&chip->mutex));
-       return _read_mac_addr(chip, chip->e2p_mac, (const zd_addr_t *)addr);
-}
-
 /* MAC address: if custom mac addresses are to to be used CR_MAC_ADDR_P1 and
  *              CR_MAC_ADDR_P2 must be overwritten
  */
-void zd_get_e2p_mac_addr(struct zd_chip *chip, u8 *mac_addr)
-{
-       mutex_lock(&chip->mutex);
-       memcpy(mac_addr, chip->e2p_mac, ETH_ALEN);
-       mutex_unlock(&chip->mutex);
-}
-
-static int read_mac_addr(struct zd_chip *chip, u8 *mac_addr)
-{
-       static const zd_addr_t addr[2] = { CR_MAC_ADDR_P1, CR_MAC_ADDR_P2 };
-       return _read_mac_addr(chip, mac_addr, (const zd_addr_t *)addr);
-}
-
-int zd_read_mac_addr(struct zd_chip *chip, u8 *mac_addr)
-{
-       int r;
-
-       dev_dbg_f(zd_chip_dev(chip), "\n");
-       mutex_lock(&chip->mutex);
-       r = read_mac_addr(chip, mac_addr);
-       mutex_unlock(&chip->mutex);
-       return r;
-}
-
 int zd_write_mac_addr(struct zd_chip *chip, const u8 *mac_addr)
 {
        int r;
@@ -443,12 +390,6 @@ int zd_write_mac_addr(struct zd_chip *chip, const u8 *mac_addr)
 
        mutex_lock(&chip->mutex);
        r = zd_iowrite32a_locked(chip, reqs, ARRAY_SIZE(reqs));
-#ifdef DEBUG
-       {
-               u8 tmp[ETH_ALEN];
-               read_mac_addr(chip, tmp);
-       }
-#endif /* DEBUG */
        mutex_unlock(&chip->mutex);
        return r;
 }
@@ -559,8 +500,6 @@ int zd_chip_lock_phy_regs(struct zd_chip *chip)
                return r;
        }
 
-       dev_dbg_f(zd_chip_dev(chip),
-               "CR_REG1: 0x%02x -> 0x%02x\n", tmp, tmp & ~UNLOCK_PHY_REGS);
        tmp &= ~UNLOCK_PHY_REGS;
 
        r = zd_iowrite32_locked(chip, tmp, CR_REG1);
@@ -582,8 +521,6 @@ int zd_chip_unlock_phy_regs(struct zd_chip *chip)
                return r;
        }
 
-       dev_dbg_f(zd_chip_dev(chip),
-               "CR_REG1: 0x%02x -> 0x%02x\n", tmp, tmp | UNLOCK_PHY_REGS);
        tmp |= UNLOCK_PHY_REGS;
 
        r = zd_iowrite32_locked(chip, tmp, CR_REG1);
@@ -614,16 +551,24 @@ static int patch_cr157(struct zd_chip *chip)
  * Vendor driver says: for FCC regulation, enabled per HWFeature 6M band edge
  * bit (for AL2230, AL2230S)
  */
-static int patch_6m_band_edge(struct zd_chip *chip, int channel)
+static int patch_6m_band_edge(struct zd_chip *chip, u8 channel)
+{
+       ZD_ASSERT(mutex_is_locked(&chip->mutex));
+       if (!chip->patch_6m_band_edge)
+               return 0;
+
+       return zd_rf_patch_6m_band_edge(&chip->rf, channel);
+}
+
+/* Generic implementation of 6M band edge patching, used by most RFs via
+ * zd_rf_generic_patch_6m() */
+int zd_chip_generic_patch_6m_band(struct zd_chip *chip, int channel)
 {
        struct zd_ioreq16 ioreqs[] = {
                { CR128, 0x14 }, { CR129, 0x12 }, { CR130, 0x10 },
                { CR47,  0x1e },
        };
 
-       if (!chip->patch_6m_band_edge || !chip->rf.patch_6m_band_edge)
-               return 0;
-
        /* FIXME: Channel 11 is not the edge for all regulatory domains. */
        if (channel == 1 || channel == 11)
                ioreqs[0].value = 0x12;
@@ -683,17 +628,17 @@ static int zd1211_hw_reset_phy(struct zd_chip *chip)
                { CR111, 0x27 }, { CR112, 0x27 }, { CR113, 0x27 },
                { CR114, 0x27 }, { CR115, 0x26 }, { CR116, 0x24 },
                { CR117, 0xfc }, { CR118, 0xfa }, { CR120, 0x4f },
-               { CR123, 0x27 }, { CR125, 0xaa }, { CR127, 0x03 },
-               { CR128, 0x14 }, { CR129, 0x12 }, { CR130, 0x10 },
-               { CR131, 0x0C }, { CR136, 0xdf }, { CR137, 0x40 },
-               { CR138, 0xa0 }, { CR139, 0xb0 }, { CR140, 0x99 },
-               { CR141, 0x82 }, { CR142, 0x54 }, { CR143, 0x1c },
-               { CR144, 0x6c }, { CR147, 0x07 }, { CR148, 0x4c },
-               { CR149, 0x50 }, { CR150, 0x0e }, { CR151, 0x18 },
-               { CR160, 0xfe }, { CR161, 0xee }, { CR162, 0xaa },
-               { CR163, 0xfa }, { CR164, 0xfa }, { CR165, 0xea },
-               { CR166, 0xbe }, { CR167, 0xbe }, { CR168, 0x6a },
-               { CR169, 0xba }, { CR170, 0xba }, { CR171, 0xba },
+               { CR125, 0xaa }, { CR127, 0x03 }, { CR128, 0x14 },
+               { CR129, 0x12 }, { CR130, 0x10 }, { CR131, 0x0C },
+               { CR136, 0xdf }, { CR137, 0x40 }, { CR138, 0xa0 },
+               { CR139, 0xb0 }, { CR140, 0x99 }, { CR141, 0x82 },
+               { CR142, 0x54 }, { CR143, 0x1c }, { CR144, 0x6c },
+               { CR147, 0x07 }, { CR148, 0x4c }, { CR149, 0x50 },
+               { CR150, 0x0e }, { CR151, 0x18 }, { CR160, 0xfe },
+               { CR161, 0xee }, { CR162, 0xaa }, { CR163, 0xfa },
+               { CR164, 0xfa }, { CR165, 0xea }, { CR166, 0xbe },
+               { CR167, 0xbe }, { CR168, 0x6a }, { CR169, 0xba },
+               { CR170, 0xba }, { CR171, 0xba },
                /* Note: CR204 must lead the CR203 */
                { CR204, 0x7d },
                { },
@@ -800,7 +745,7 @@ out:
 
 static int hw_reset_phy(struct zd_chip *chip)
 {
-       return chip->is_zd1211b ? zd1211b_hw_reset_phy(chip) :
+       return zd_chip_is_zd1211b(chip) ? zd1211b_hw_reset_phy(chip) :
                                  zd1211_hw_reset_phy(chip);
 }
 
@@ -865,7 +810,7 @@ static int hw_init_hmac(struct zd_chip *chip)
        if (r)
                return r;
 
-       return chip->is_zd1211b ?
+       return zd_chip_is_zd1211b(chip) ?
                zd1211b_hw_init_hmac(chip) : zd1211_hw_init_hmac(chip);
 }
 
@@ -892,8 +837,6 @@ static int get_aw_pt_bi(struct zd_chip *chip, struct aw_pt_bi *s)
        s->atim_wnd_period = values[0];
        s->pre_tbtt = values[1];
        s->beacon_interval = values[2];
-       dev_dbg_f(zd_chip_dev(chip), "aw %u pt %u bi %u\n",
-               s->atim_wnd_period, s->pre_tbtt, s->beacon_interval);
        return 0;
 }
 
@@ -915,9 +858,6 @@ static int set_aw_pt_bi(struct zd_chip *chip, struct aw_pt_bi *s)
        reqs[2].addr = CR_BCN_INTERVAL;
        reqs[2].value = s->beacon_interval;
 
-       dev_dbg_f(zd_chip_dev(chip),
-               "aw %u pt %u bi %u\n", s->atim_wnd_period, s->pre_tbtt,
-                                      s->beacon_interval);
        return zd_iowrite32a_locked(chip, reqs, ARRAY_SIZE(reqs));
 }
 
@@ -1127,8 +1067,15 @@ static int read_fw_regs_offset(struct zd_chip *chip)
        return 0;
 }
 
+/* Read mac address using pre-firmware interface */
+int zd_chip_read_mac_addr_fw(struct zd_chip *chip, u8 *addr)
+{
+       dev_dbg_f(zd_chip_dev(chip), "\n");
+       return zd_usb_read_fw(&chip->usb, E2P_MAC_ADDR_P1, addr,
+               ETH_ALEN);
+}
 
-int zd_chip_init_hw(struct zd_chip *chip, u8 device_type)
+int zd_chip_init_hw(struct zd_chip *chip)
 {
        int r;
        u8 rf_type;
@@ -1136,7 +1083,6 @@ int zd_chip_init_hw(struct zd_chip *chip, u8 device_type)
        dev_dbg_f(zd_chip_dev(chip), "\n");
 
        mutex_lock(&chip->mutex);
-       chip->is_zd1211b = (device_type == DEVICE_ZD1211B) != 0;
 
 #ifdef DEBUG
        r = test_init(chip);
@@ -1192,10 +1138,6 @@ int zd_chip_init_hw(struct zd_chip *chip, u8 device_type)
                goto out;
 #endif /* DEBUG */
 
-       r = read_e2p_mac_addr(chip);
-       if (r)
-               goto out;
-
        r = read_cal_int_tables(chip);
        if (r)
                goto out;
@@ -1209,16 +1151,12 @@ out:
 static int update_pwr_int(struct zd_chip *chip, u8 channel)
 {
        u8 value = chip->pwr_int_values[channel - 1];
-       dev_dbg_f(zd_chip_dev(chip), "channel %d pwr_int %#04x\n",
-                channel, value);
        return zd_iowrite16_locked(chip, value, CR31);
 }
 
 static int update_pwr_cal(struct zd_chip *chip, u8 channel)
 {
        u8 value = chip->pwr_cal_values[channel-1];
-       dev_dbg_f(zd_chip_dev(chip), "channel %d pwr_cal %#04x\n",
-                channel, value);
        return zd_iowrite16_locked(chip, value, CR68);
 }
 
@@ -1233,9 +1171,6 @@ static int update_ofdm_cal(struct zd_chip *chip, u8 channel)
        ioreqs[2].addr = CR65;
        ioreqs[2].value = chip->ofdm_cal_values[OFDM_54M_INDEX][channel-1];
 
-       dev_dbg_f(zd_chip_dev(chip),
-               "channel %d ofdm_cal 36M %#04x 48M %#04x 54M %#04x\n",
-               channel, ioreqs[0].value, ioreqs[1].value, ioreqs[2].value);
        return zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
 }
 
@@ -1244,10 +1179,13 @@ static int update_channel_integration_and_calibration(struct zd_chip *chip,
 {
        int r;
 
+       if (!zd_rf_should_update_pwr_int(&chip->rf))
+               return 0;
+
        r = update_pwr_int(chip, channel);
        if (r)
                return r;
-       if (chip->is_zd1211b) {
+       if (zd_chip_is_zd1211b(chip)) {
                static const struct zd_ioreq16 ioreqs[] = {
                        { CR69, 0x28 },
                        {},
@@ -1274,7 +1212,7 @@ static int patch_cck_gain(struct zd_chip *chip)
        int r;
        u32 value;
 
-       if (!chip->patch_cck_gain)
+       if (!chip->patch_cck_gain || !zd_rf_should_patch_cck_gain(&chip->rf))
                return 0;
 
        ZD_ASSERT(mutex_is_locked(&chip->mutex));
@@ -1684,7 +1622,5 @@ int zd_chip_set_multicast_hash(struct zd_chip *chip,
                { CR_GROUP_HASH_P2, hash->high },
        };
 
-       dev_dbg_f(zd_chip_dev(chip), "hash l 0x%08x h 0x%08x\n",
-               ioreqs[0].value, ioreqs[1].value);
        return zd_iowrite32a(chip, ioreqs, ARRAY_SIZE(ioreqs));
 }