diff options
author | Daniel Drake <dsd@gentoo.org> | 2006-12-11 20:25:52 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-02-05 16:58:42 -0500 |
commit | ee30276774451d657407855d95d9393ee8bc0bac (patch) | |
tree | ceb02ea0a59acf90ac532c72e7ff294c2736f9a4 | |
parent | a2bdcc679288307f9237c9611a0cc0c3c06669a9 (diff) |
[PATCH] zd1211rw: Consistency for address space constants
The zd1211rw address space has confused me once too many times. This
patch introduces the following naming notation:
Memory space is split into segments (cr, fw, eeprom) and segments may
contain components (e.g. boot code inside eeprom). These names are
arbitrary and only for the description below:
x_START: Absolute address of segment start
(previously these were named such as CR_BASE_OFFSET, but they weren't
really offsets unless you were considering them as an offset to 0)
x_LEN: Segment length
x_y_LEN: Length of component y of segment x
x_y_OFFSET: Relative address of component y into segment x. The absolute
address for this component is (x_START + x_y_OFFSET)
I also renamed EEPROM registers to EEPROM data. These 'registers' can't
be written to using standard I/O and really represent predefined data
from the vendor.
Signed-off-by: Daniel Drake <dsd@gentoo.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | drivers/net/wireless/zd1211rw/zd_chip.h | 119 | ||||
-rw-r--r-- | drivers/net/wireless/zd1211rw/zd_types.h | 2 | ||||
-rw-r--r-- | drivers/net/wireless/zd1211rw/zd_usb.c | 18 |
3 files changed, 75 insertions, 64 deletions
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.h b/drivers/net/wireless/zd1211rw/zd_chip.h index a4e3cee9b59d..fa3437d6d742 100644 --- a/drivers/net/wireless/zd1211rw/zd_chip.h +++ b/drivers/net/wireless/zd1211rw/zd_chip.h | |||
@@ -594,49 +594,49 @@ | |||
594 | /* | 594 | /* |
595 | * Upper 16 bit contains the regulatory domain. | 595 | * Upper 16 bit contains the regulatory domain. |
596 | */ | 596 | */ |
597 | #define E2P_SUBID E2P_REG(0x00) | 597 | #define E2P_SUBID E2P_DATA(0x00) |
598 | #define E2P_POD E2P_REG(0x02) | 598 | #define E2P_POD E2P_DATA(0x02) |
599 | #define E2P_MAC_ADDR_P1 E2P_REG(0x04) | 599 | #define E2P_MAC_ADDR_P1 E2P_DATA(0x04) |
600 | #define E2P_MAC_ADDR_P2 E2P_REG(0x06) | 600 | #define E2P_MAC_ADDR_P2 E2P_DATA(0x06) |
601 | #define E2P_PWR_CAL_VALUE1 E2P_REG(0x08) | 601 | #define E2P_PWR_CAL_VALUE1 E2P_DATA(0x08) |
602 | #define E2P_PWR_CAL_VALUE2 E2P_REG(0x0a) | 602 | #define E2P_PWR_CAL_VALUE2 E2P_DATA(0x0a) |
603 | #define E2P_PWR_CAL_VALUE3 E2P_REG(0x0c) | 603 | #define E2P_PWR_CAL_VALUE3 E2P_DATA(0x0c) |
604 | #define E2P_PWR_CAL_VALUE4 E2P_REG(0x0e) | 604 | #define E2P_PWR_CAL_VALUE4 E2P_DATA(0x0e) |
605 | #define E2P_PWR_INT_VALUE1 E2P_REG(0x10) | 605 | #define E2P_PWR_INT_VALUE1 E2P_DATA(0x10) |
606 | #define E2P_PWR_INT_VALUE2 E2P_REG(0x12) | 606 | #define E2P_PWR_INT_VALUE2 E2P_DATA(0x12) |
607 | #define E2P_PWR_INT_VALUE3 E2P_REG(0x14) | 607 | #define E2P_PWR_INT_VALUE3 E2P_DATA(0x14) |
608 | #define E2P_PWR_INT_VALUE4 E2P_REG(0x16) | 608 | #define E2P_PWR_INT_VALUE4 E2P_DATA(0x16) |
609 | 609 | ||
610 | /* Contains a bit for each allowed channel. It gives for Europe (ETSI 0x30) | 610 | /* Contains a bit for each allowed channel. It gives for Europe (ETSI 0x30) |
611 | * also only 11 channels. */ | 611 | * also only 11 channels. */ |
612 | #define E2P_ALLOWED_CHANNEL E2P_REG(0x18) | 612 | #define E2P_ALLOWED_CHANNEL E2P_DATA(0x18) |
613 | 613 | ||
614 | #define E2P_PHY_REG E2P_REG(0x1a) | 614 | #define E2P_PHY_REG E2P_DATA(0x1a) |
615 | #define E2P_DEVICE_VER E2P_REG(0x20) | 615 | #define E2P_DEVICE_VER E2P_DATA(0x20) |
616 | #define E2P_36M_CAL_VALUE1 E2P_REG(0x28) | 616 | #define E2P_36M_CAL_VALUE1 E2P_DATA(0x28) |
617 | #define E2P_36M_CAL_VALUE2 E2P_REG(0x2a) | 617 | #define E2P_36M_CAL_VALUE2 E2P_DATA(0x2a) |
618 | #define E2P_36M_CAL_VALUE3 E2P_REG(0x2c) | 618 | #define E2P_36M_CAL_VALUE3 E2P_DATA(0x2c) |
619 | #define E2P_36M_CAL_VALUE4 E2P_REG(0x2e) | 619 | #define E2P_36M_CAL_VALUE4 E2P_DATA(0x2e) |
620 | #define E2P_11A_INT_VALUE1 E2P_REG(0x30) | 620 | #define E2P_11A_INT_VALUE1 E2P_DATA(0x30) |
621 | #define E2P_11A_INT_VALUE2 E2P_REG(0x32) | 621 | #define E2P_11A_INT_VALUE2 E2P_DATA(0x32) |
622 | #define E2P_11A_INT_VALUE3 E2P_REG(0x34) | 622 | #define E2P_11A_INT_VALUE3 E2P_DATA(0x34) |
623 | #define E2P_11A_INT_VALUE4 E2P_REG(0x36) | 623 | #define E2P_11A_INT_VALUE4 E2P_DATA(0x36) |
624 | #define E2P_48M_CAL_VALUE1 E2P_REG(0x38) | 624 | #define E2P_48M_CAL_VALUE1 E2P_DATA(0x38) |
625 | #define E2P_48M_CAL_VALUE2 E2P_REG(0x3a) | 625 | #define E2P_48M_CAL_VALUE2 E2P_DATA(0x3a) |
626 | #define E2P_48M_CAL_VALUE3 E2P_REG(0x3c) | 626 | #define E2P_48M_CAL_VALUE3 E2P_DATA(0x3c) |
627 | #define E2P_48M_CAL_VALUE4 E2P_REG(0x3e) | 627 | #define E2P_48M_CAL_VALUE4 E2P_DATA(0x3e) |
628 | #define E2P_48M_INT_VALUE1 E2P_REG(0x40) | 628 | #define E2P_48M_INT_VALUE1 E2P_DATA(0x40) |
629 | #define E2P_48M_INT_VALUE2 E2P_REG(0x42) | 629 | #define E2P_48M_INT_VALUE2 E2P_DATA(0x42) |
630 | #define E2P_48M_INT_VALUE3 E2P_REG(0x44) | 630 | #define E2P_48M_INT_VALUE3 E2P_DATA(0x44) |
631 | #define E2P_48M_INT_VALUE4 E2P_REG(0x46) | 631 | #define E2P_48M_INT_VALUE4 E2P_DATA(0x46) |
632 | #define E2P_54M_CAL_VALUE1 E2P_REG(0x48) /* ??? */ | 632 | #define E2P_54M_CAL_VALUE1 E2P_DATA(0x48) /* ??? */ |
633 | #define E2P_54M_CAL_VALUE2 E2P_REG(0x4a) | 633 | #define E2P_54M_CAL_VALUE2 E2P_DATA(0x4a) |
634 | #define E2P_54M_CAL_VALUE3 E2P_REG(0x4c) | 634 | #define E2P_54M_CAL_VALUE3 E2P_DATA(0x4c) |
635 | #define E2P_54M_CAL_VALUE4 E2P_REG(0x4e) | 635 | #define E2P_54M_CAL_VALUE4 E2P_DATA(0x4e) |
636 | #define E2P_54M_INT_VALUE1 E2P_REG(0x50) | 636 | #define E2P_54M_INT_VALUE1 E2P_DATA(0x50) |
637 | #define E2P_54M_INT_VALUE2 E2P_REG(0x52) | 637 | #define E2P_54M_INT_VALUE2 E2P_DATA(0x52) |
638 | #define E2P_54M_INT_VALUE3 E2P_REG(0x54) | 638 | #define E2P_54M_INT_VALUE3 E2P_DATA(0x54) |
639 | #define E2P_54M_INT_VALUE4 E2P_REG(0x56) | 639 | #define E2P_54M_INT_VALUE4 E2P_DATA(0x56) |
640 | 640 | ||
641 | /* All 16 bit values */ | 641 | /* All 16 bit values */ |
642 | #define FW_FIRMWARE_VER FW_REG(0) | 642 | #define FW_FIRMWARE_VER FW_REG(0) |
@@ -653,20 +653,33 @@ | |||
653 | /* 0x2 - link led on? */ | 653 | /* 0x2 - link led on? */ |
654 | 654 | ||
655 | enum { | 655 | enum { |
656 | CR_BASE_OFFSET = 0x9000, | 656 | /* CONTROL REGISTERS */ |
657 | FW_START_OFFSET = 0xee00, | 657 | CR_START = 0x9000, |
658 | FW_BASE_ADDR_OFFSET = FW_START_OFFSET + 0x1d, | 658 | |
659 | EEPROM_START_OFFSET = 0xf800, | 659 | /* FIRMWARE */ |
660 | EEPROM_SIZE = 0x800, /* words */ | 660 | FW_START = 0xee00, |
661 | LOAD_CODE_SIZE = 0xe, /* words */ | 661 | |
662 | LOAD_VECT_SIZE = 0x10000 - 0xfff7, /* words */ | 662 | /* The word at this offset contains the base address of the FW_REG |
663 | EEPROM_REGS_OFFSET = LOAD_CODE_SIZE + LOAD_VECT_SIZE, | 663 | * registers */ |
664 | EEPROM_REGS_SIZE = 0x7e, /* words */ | 664 | FW_REGS_ADDR_OFFSET = 0x1d, |
665 | E2P_BASE_OFFSET = EEPROM_START_OFFSET + | 665 | |
666 | EEPROM_REGS_OFFSET, | ||
667 | }; | ||
668 | 666 | ||
669 | #define FW_REG_TABLE_ADDR USB_ADDR(FW_START_OFFSET + 0x1d) | 667 | /* EEPROM */ |
668 | E2P_START = 0xf800, | ||
669 | E2P_LEN = 0x800, | ||
670 | |||
671 | /* EEPROM layout */ | ||
672 | E2P_LOAD_CODE_LEN = 0xe, /* base 0xf800 */ | ||
673 | E2P_LOAD_VECT_LEN = 0x9, /* base 0xf80e */ | ||
674 | /* E2P_DATA indexes into this */ | ||
675 | E2P_DATA_LEN = 0x7e, /* base 0xf817 */ | ||
676 | E2P_BOOT_CODE_LEN = 0x760, /* base 0xf895 */ | ||
677 | E2P_INTR_VECT_LEN = 0xb, /* base 0xfff5 */ | ||
678 | |||
679 | /* Some precomputed offsets into the EEPROM */ | ||
680 | E2P_DATA_OFFSET = E2P_LOAD_CODE_LEN + E2P_LOAD_VECT_LEN, | ||
681 | E2P_BOOT_CODE_OFFSET = E2P_DATA_OFFSET + E2P_DATA_LEN, | ||
682 | }; | ||
670 | 683 | ||
671 | enum { | 684 | enum { |
672 | /* indices for ofdm_cal_values */ | 685 | /* indices for ofdm_cal_values */ |
diff --git a/drivers/net/wireless/zd1211rw/zd_types.h b/drivers/net/wireless/zd1211rw/zd_types.h index 0155a1584ed3..b3d642833e2c 100644 --- a/drivers/net/wireless/zd1211rw/zd_types.h +++ b/drivers/net/wireless/zd1211rw/zd_types.h | |||
@@ -55,7 +55,7 @@ enum { | |||
55 | #define ZD_NULL_ADDR ((zd_addr_t)0) | 55 | #define ZD_NULL_ADDR ((zd_addr_t)0) |
56 | #define USB_REG(offset) ZD_ADDR(USB_BASE, offset) /* word addressing */ | 56 | #define USB_REG(offset) ZD_ADDR(USB_BASE, offset) /* word addressing */ |
57 | #define CTL_REG(offset) ZD_ADDR(CR_BASE, offset) /* byte addressing */ | 57 | #define CTL_REG(offset) ZD_ADDR(CR_BASE, offset) /* byte addressing */ |
58 | #define E2P_REG(offset) ZD_ADDR(E2P_BASE, offset) /* word addressing */ | 58 | #define E2P_DATA(offset) ZD_ADDR(E2P_BASE, offset) /* word addressing */ |
59 | #define FW_REG(offset) ZD_ADDR(FW_BASE, offset) /* word addressing */ | 59 | #define FW_REG(offset) ZD_ADDR(FW_BASE, offset) /* word addressing */ |
60 | 60 | ||
61 | static inline zd_addr_t zd_inc_word(zd_addr_t addr) | 61 | static inline zd_addr_t zd_inc_word(zd_addr_t addr) |
diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c index b061d11d4ab0..6a524409aeac 100644 --- a/drivers/net/wireless/zd1211rw/zd_usb.c +++ b/drivers/net/wireless/zd1211rw/zd_usb.c | |||
@@ -152,10 +152,10 @@ static u16 usb_addr(struct zd_usb *usb, zd_addr_t addr) | |||
152 | 152 | ||
153 | switch (base) { | 153 | switch (base) { |
154 | case CR_BASE: | 154 | case CR_BASE: |
155 | offset += CR_BASE_OFFSET; | 155 | offset += CR_START; |
156 | break; | 156 | break; |
157 | case E2P_BASE: | 157 | case E2P_BASE: |
158 | offset += E2P_BASE_OFFSET; | 158 | offset += E2P_START + E2P_DATA_OFFSET; |
159 | break; | 159 | break; |
160 | case FW_BASE: | 160 | case FW_BASE: |
161 | offset += usb->fw_base_offset; | 161 | offset += usb->fw_base_offset; |
@@ -297,14 +297,13 @@ static int handle_version_mismatch(struct usb_device *udev, u8 device_type, | |||
297 | if (r) | 297 | if (r) |
298 | goto error; | 298 | goto error; |
299 | 299 | ||
300 | r = upload_code(udev, ur_fw->data, ur_fw->size, FW_START_OFFSET, | 300 | r = upload_code(udev, ur_fw->data, ur_fw->size, FW_START, REBOOT); |
301 | REBOOT); | ||
302 | if (r) | 301 | if (r) |
303 | goto error; | 302 | goto error; |
304 | 303 | ||
305 | offset = ((EEPROM_REGS_OFFSET + EEPROM_REGS_SIZE) * sizeof(u16)); | 304 | offset = (E2P_BOOT_CODE_OFFSET * sizeof(u16)); |
306 | r = upload_code(udev, ub_fw->data + offset, ub_fw->size - offset, | 305 | r = upload_code(udev, ub_fw->data + offset, ub_fw->size - offset, |
307 | E2P_BASE_OFFSET + EEPROM_REGS_SIZE, REBOOT); | 306 | E2P_START + E2P_BOOT_CODE_OFFSET, REBOOT); |
308 | 307 | ||
309 | /* At this point, the vendor driver downloads the whole firmware | 308 | /* At this point, the vendor driver downloads the whole firmware |
310 | * image, hacks around with version IDs, and uploads it again, | 309 | * image, hacks around with version IDs, and uploads it again, |
@@ -333,7 +332,7 @@ static int upload_firmware(struct usb_device *udev, u8 device_type) | |||
333 | if (r) | 332 | if (r) |
334 | goto error; | 333 | goto error; |
335 | 334 | ||
336 | fw_bcdDevice = get_word(ub_fw->data, EEPROM_REGS_OFFSET); | 335 | fw_bcdDevice = get_word(ub_fw->data, E2P_DATA_OFFSET); |
337 | 336 | ||
338 | if (fw_bcdDevice != bcdDevice) { | 337 | if (fw_bcdDevice != bcdDevice) { |
339 | dev_info(&udev->dev, | 338 | dev_info(&udev->dev, |
@@ -359,8 +358,7 @@ static int upload_firmware(struct usb_device *udev, u8 device_type) | |||
359 | if (r) | 358 | if (r) |
360 | goto error; | 359 | goto error; |
361 | 360 | ||
362 | r = upload_code(udev, uph_fw->data, uph_fw->size, FW_START_OFFSET, | 361 | r = upload_code(udev, uph_fw->data, uph_fw->size, FW_START, REBOOT); |
363 | REBOOT); | ||
364 | if (r) { | 362 | if (r) { |
365 | dev_err(&udev->dev, | 363 | dev_err(&udev->dev, |
366 | "Could not upload firmware code uph. Error number %d\n", | 364 | "Could not upload firmware code uph. Error number %d\n", |
@@ -899,7 +897,7 @@ int zd_usb_init_hw(struct zd_usb *usb) | |||
899 | 897 | ||
900 | ZD_ASSERT(mutex_is_locked(&chip->mutex)); | 898 | ZD_ASSERT(mutex_is_locked(&chip->mutex)); |
901 | r = zd_ioread16_locked(chip, &usb->fw_base_offset, | 899 | r = zd_ioread16_locked(chip, &usb->fw_base_offset, |
902 | USB_REG((u16)FW_BASE_ADDR_OFFSET)); | 900 | USB_REG(FW_START + FW_REGS_ADDR_OFFSET)); |
903 | if (r) | 901 | if (r) |
904 | return r; | 902 | return r; |
905 | dev_dbg_f(zd_usb_dev(usb), "fw_base_offset: %#06hx\n", | 903 | dev_dbg_f(zd_usb_dev(usb), "fw_base_offset: %#06hx\n", |